﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"qdebug.h"
#include"qdesktopwidget.h"
#include"QTextCharFormat"
#include "qscrollarea.h"
#include"qscrollbar.h"
#include"qcursor.h"
#include"qpoint.h"
#include"qmenu.h"
#include"qmenubar.h"
#include "config.h"
#include"domainobject.h"
#include"qtextcodec.h"
#include"QDir"
#include"gyscada.h"
#include "db.h"
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
   actionControl = new ActionControl(this);
    QDesktopWidget *deskWiget=QApplication::desktop();
    deskWidth=deskWiget->width();
    deskHeight=deskWiget->height();
    QDir::setCurrent(QApplication::applicationDirPath());
    QTextCodec* code=QTextCodec::codecForName("utf-8");

    QTextCodec::setCodecForLocale(code);
    GYSCADAConfig::getInstance()->parse();
    GYSCADA::getInstance();
    if (!GYSCADADB::getInstance()->isOpen()) {
        QMessageBox::critical(NULL, QObject::tr("数据库链接失败"), GYSCADADB::getInstance()->lastError());
        return ;
    }

    QString userName = "gyee";
    QString password = "1";

    if (GYSCADADB::getInstance()->verify(userName, password)) {
        GYSCADAConfig::getInstance()->setStafferName(GYSCADADB::getInstance()->getStafferName(userName, password));
        GYSCADAConfig::getInstance()->setUserId(GYSCADADB::getInstance()->getUserId(userName, password));
        GYSCADAConfig::getInstance()->setUserName(userName);

       // this->accept();
    } else {
        QMessageBox::critical(NULL, tr("错误"), tr("登录失败，用户名或者密码不正确！"));
    }




    F_matrixControlForm=new MatrixControlForm;
    p_matrixmenuForm=new MatrixmenuForm;
   this->setStates();
this->showFullScreen();


    qDebug()<<deskWiget->width()<<"deskwidth";
    //qDebug()<<deskWiget->height();
 //this->setWindowState(Qt::WindowMaximized);
   // this->setGeometry(0,0,1366,768);
 //this->showMaximized();

    ui->stackedWidget->setCurrentIndex(0);
    connect(timer,SIGNAL(timeout()),this,SLOT(time_end()));
     timer->start(100);


     /*ui->tableView->setAttribute(Qt::WA_TranslucentBackground,true);
     QPalette pa;
     QColor color(100,100,100);
     pa.setBrush(ui->tableView->backgroundRole(),color);
     ui->tableView->setPalette(pa);
     ui->tableView->setStyleSheet("border:0px");
     ui->tableView->setAutoFillBackground(true);
*/
     connect(ui->tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),ui->tableWidget,SLOT(resizeRowsToContents()));
  ui->tableWidget->setRowHeight(0,1000);
  QString str="676";
  QFont f;
 // const ushort *s='asd';
 const char * p="345345";
//p->setCell('234324');
 // str.setUtf16(p,20);
  QString str2=QObject::tr("<font color=\"#B10E7E\"  size=20>%1</font>").arg("454")+QObject::tr("<font font color=\"#0EB124\"  size=10>%1</font>").arg("   sf454");

//  str2=QString("<span style=font-size:80px;color:red;>%1</span>").arg("QT!") +QString("<span style=font-size:80px;color:red;>%1</span>").arg("hhjhgj!");
ui->label_6->setText(str2);



          QTableWidgetItem *item0, *item1,*item2, *item3;
          item0 = new QTableWidgetItem;

          item0->setText(str2);


          ui->tableWidget->setItem(0, 1, item0);


  //  ui->label_17->installEventFilter(this);
         p_clickMenuWidget=new QWidget(this);
         p_clickMenuWidget->setStyleSheet("color: rgb(255, 255, 255);\
                                             border-width: 1.4px;\
                                             border-color: #31b9fb;\
                                             border-bottom-color: #31b9fb;\
                                             border-style: solid;\
                                             background-color: #031830;\
                                            ");
                                             p_clickMenuWidget->hide();



                                            /* p_menu=new QMenu(p_matrixmenuForm);
                                                 QAction* a1=new QAction("启动",ui->widget_2);
                                                  QAction* a2=new QAction("停机",ui->widget_2);
                                                  QAction* a3=new QAction("复位",ui->widget_2);
                                                  QAction* a4=new QAction("维护",ui->widget_2);
                                                  QAction* a5=new QAction("取消维护",ui->widget_2);
                                                  p_menu->addSection("风场信息");
                                                  p_menu->addAction(a1);
                                                  p_menu->addAction(a2);
                                                  p_menu->addAction(a3);
                                                  p_menu->addAction(a4);
                                                  p_menu->addAction(a5);*/



                                             LayoutWidget=new QWidget(this);


       connect(this,SIGNAL(sendMatrixFJEnter(int,int)),this,SLOT(show_menu(int,int)));
       connect(this,SIGNAL(setFengChangFJName(int,int,QString)),this,SLOT(setFengChangFjName_Slots(int,int,QString)));
        connect(this,SIGNAL(setFengChangFJNums(int,int,QString,QString,QString)),this,SLOT(setFengChangFjNums_Slots(int,int,QString,QString,QString)));
        connect(this,SIGNAL(setFengChangFJTops(int,QString,QString,QList<int>)),this,SLOT(setFengChangFjTops_Slots(int,QString,QString,QList<int>)));
         connect(this,SIGNAL(setMatrixTops(QList<int>,QString,QString)),this,SLOT(setMatrixTops_Slots(QList<int>,QString,QString)));




       this->setMatrixNames();
       this->setMatrixNums();

          connect(p_matrixmenuForm,SIGNAL(startButton()),this,SLOT(menuStart()));
          connect(p_matrixmenuForm,SIGNAL(stopButton()),this,SLOT(menuStop()));
           connect(p_matrixmenuForm,SIGNAL(resetButton()),this,SLOT(menuReset()));
                  connect(p_matrixmenuForm,SIGNAL(repairButton()),this,SLOT(menuRepair()));
                  connect(p_matrixmenuForm,SIGNAL(unrepairButton()),this,SLOT(menuUnrepair()));



    }

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::changeEvent(QEvent *e)
{



  //  qDebug()<<"maxScreen";
    double x,y,z,k,k2,k3,w1,w2,w3,w4,w5;
     x=this->width();
     //qDebug()<<this->width()<<ui->widget->width();

      z=ui->manageButton->width();
      y=ui->hostButton->width();
      k=ui->controlButton->width();
      k2=ui->boosterButton->width();
      k3=ui->label_14->width();
      w1=y/x;
      w2=z/x;
      w3=k/x;
      w4=k2/x;
      w5=k3/x;


    x=ui->mainParameterButton->height();
    y=ui->centralWidget->height();

   // qDebug()<<x/y<<endl;
     w1=0.0508351;
      w2=0.0980392;
      w3=0.0617284;
      w4=0.0617284;
      w5=0.0617284;

    int h1,h2,h3,h4,h5;
    h1=w1*ui->widget->width();
//    qDebug()<<h1;

   ui->widget->setFixedHeight(0.0708215*ui->centralWidget->height());
    ui->hostButton->setFixedSize(w1*ui->widget->width(),ui->widget->height()*0.87);
      ui->controlButton->setFixedSize(w3*ui->widget->width(),ui->widget->height()*0.87);
      ui->mainParameterButton->setFixedSize(w3*ui->widget->width(),ui->widget->height()*0.87);
     ui->parameterButton->setFixedSize(w3*ui->widget->width(),ui->widget->height()*0.87);
      ui->matrixButton->setFixedSize(w3*ui->widget->width(),ui->widget->height()*0.87);
     ui->searchButton->setFixedSize(w3*ui->widget->width(),ui->widget->height()*0.87);
      ui->manageButton->setFixedSize(w2*ui->widget->width(),ui->widget->height()*0.87);
      ui->label_14->setFixedSize(w5*ui->widget->width(),ui->widget->height()*0.87);
      ui->boosterButton->setFixedSize(w4*ui->widget->width(),ui->widget->height()*0.87);
      /* ui->widget->setFixedHeight(0.0708215*ui->centralWidget->height());
       ui->hostButton->setFixedHeight(ui->widget->height());
         ui->controlButton->setFixedHeight(ui->widget->height());
         ui->mainParameterButton->setFixedHeight(ui->widget->height());
        ui->parameterButton->setFixedHeight(ui->widget->height());
         ui->matrixButton->setFixedHeight(ui->widget->height());
      //   ui->hostButton->setFixedHeight(ui->widget->height());
         ui->manageButton->setFixedHeight(ui->widget->height());
         ui->label_14->setFixedHeight(ui->widget->height());
         ui->boosterButton->setFixedHeight(ui->widget->height());*/
   /*   qDebug()<<w1<<"    "<<w2<<"  "<<"   "<<w3<<"    "<<w4<<"   "<<w5<<endl;

      qDebug()<<ui->hostButton->width();
      qDebug()<<ui->boosterButton->width();
      qDebug()<<ui->mainParameterButton->width();
      qDebug()<<ui->parameterButton->width();
      qDebug()<<ui->manageButton->width();
      qDebug()<<ui->matrixButton->width();
      qDebug()<<ui->controlButton->width();
      qDebug()<<ui->searchButton->width();
      qDebug()<<ui->label_14->width();*/

      if(ui->stackedWidget->currentIndex()==0&&timeStart_falg){

     //    qDebug()<<ui->centralWidget->height();

         this->showWindowMax();

      }



}

void MainWindow::setStates()
{
    //ui->verticalLayout_35->setSpacing(0);
 //   ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    for(int i=0;i<10;i++){
        p_lable[i]=new QLabel(this);
        p_lable[i]->setStyleSheet("color: rgb(255, 255, 255);\
                                  border-width: 1.4px;\
                                  border-color: #31b9fb;\
                                  border-bottom-color: #31b9fb;\
                                     background-color: #031830;\
                                  border-style: solid;");
        //p_lable[i]->setFixedSize(ui->widget_3->width(),100);
      p_lable[i]->hide();



    }


    for(int i=0;i<7;i++){


              p_state[i]=new PDState;
         p_state[i]->p_widget=new QWidget(this);
         p_state[i]->p_state=new QLabel(this);
         p_state[i]->p_num=new QLabel(this);
         p_state[i]->p_lable=new QLabel(this);
         p_state[i]->p_icon=new QLabel(this);
          p_state[i]->p_num->setAlignment(Qt::AlignCenter);
          p_state[i]->p_lable->setAlignment(Qt::AlignCenter);
           p_state[i]->p_state->setAlignment(Qt::AlignCenter);
        p_state[i]->p_HLayout=new QHBoxLayout(p_state[i]->p_widget);
        p_state[i]->p_widget->setFixedSize(200,35);
        p_state[i]->p_widget->setContentsMargins(0,0,0,0);
         p_state[i]->p_HLayout->setSpacing(0);
        p_state[i]->p_widget->setStyleSheet("color: rgb(255, 255, 255);\
                                            border-width: 1.4px;\
                                            border-color: #31b9fb;\
                                            border-bottom-color: #31b9fb;\
                                            border-style: solid;\
                                            background-color: #031830;\
                                           ");

        p_state[i]->p_state->setStyleSheet("border-width: 0px;\
                                           color: #31b9fb;");
         p_state[i]->p_num->setStyleSheet("border-width: 0px;\
                                          color: #31b9fb;");
          p_state[i]->p_lable->setStyleSheet("border-width: 0px;\
                                              color: #31b9fb;");
          p_state[i]->p_icon->setStyleSheet("border-width: 0px;");

        p_state[i]->p_state->setText("接入");
        p_state[i]->p_num->setText("1234");
        p_state[i]->p_lable->setText("台");
      //  p_state[i]->p_icon->setFixedSize(30,30);
         p_state[i]->p_HLayout->addWidget(p_state[i]->p_icon,1);
        p_state[i]->p_HLayout->addWidget(p_state[i]->p_state,1);
        p_state[i]->p_HLayout->addWidget(p_state[i]->p_num,1);
        p_state[i]->p_HLayout->addWidget(p_state[i]->p_lable,1);

    }

 /*   p_state[0]->p_icon->setStyleSheet("border-image: url(:/new/images/images/icon1.png);\
                                      border-width: 0px;\
                                      ");
     p_state[1]->p_icon->setStyleSheet("background-image: url(:/new/images/images/icon1.png);");
      p_state[2]->p_icon->setStyleSheet("background-image: url(:/new/images/images/icon1.png);\
                                        border-width: 0px;");
      p_state[3]->p_icon->setStyleSheet("border-image: url(:/new/images/images/icon4png);");
      p_state[4]->p_icon->setStyleSheet("image: url(:/new/images/images/icon5.png);\
                                        border-width: 0px;");
       p_state[5]->p_icon->setStyleSheet("border-image: url(:/new/images/images/icon6.png);");
        p_state[6]->p_icon->setStyleSheet("border-image: url(:/new/images/images/icon7.png);");

*/

    p_topleftwidget=new QWidget(this);
    p_VTopleftLayout=new QVBoxLayout(p_topleftwidget);
    p_VTopleftLayout->setSpacing(0);
    p_topleftwidget->setContentsMargins(7,0,0,0);
   p_topleftwidget->setStyleSheet("color: rgb(255, 255, 255);\
                                  border-width: 1.4px;\
                                  border-color: #31b9fb;\
                                  border-bottom-color: #31b9fb;\
                                   background-color: #031830;\
                                  border-style: solid;");

    p_topleftlable=new QLabel(this);
    p_topleftlable->setFixedSize(190,1.4);
    p_topleftlable->setStyleSheet("color: rgb(255, 255, 255);\
                                  border-width: 1.4px;\
                                  border-color: #31b9fb;\
                                  border-bottom-color: #31b9fb;\
                                    background-color: #031830;\
                                  border-style: solid;");

    p_topleftwidget->setFixedSize(200,200);
    for(int i=0;i<8;i++){
        p_topleftState[i]=new PDTopLeftState;

       p_topleftState[i]->p_state=new QLabel(this);
        p_topleftState[i]->p_num=new QLabel(this);
        p_topleftState[i]->p_lable=new QLabel(this);
        p_topleftState[i]->p_HLayout=new QHBoxLayout(this);
        p_topleftState[i]->p_state->setAlignment(Qt::AlignLeft);
        p_topleftState[i]->p_state->setAlignment(Qt::AlignVCenter);
        p_topleftState[i]->p_num->setAlignment(Qt::AlignCenter);
        //p_topleftState[i]->p_num->setAlignment(Qt::AlignVCenter);
         p_topleftState[i]->p_lable->setAlignment(Qt::AlignCenter);
         p_topleftState[i]->p_HLayout->setSpacing(0);
         p_topleftState[i]->p_state->setStyleSheet("border-width: 0px;\
                                                   color: #31b9fb;");
          p_topleftState[i]->p_num->setStyleSheet("border-width: 0px;\
                                                  color: #31b9fb;");
           p_topleftState[i]->p_lable->setStyleSheet("border-width: 0px;\
                                                     color: #31b9fb;");
        p_topleftState[i]->p_state->setText("接入");
        p_topleftState[i]->p_num->setText("7777.5");
       p_topleftState[i]->p_lable->setText("MW");
       p_topleftState[i]->p_HLayout->addWidget(p_topleftState[i]->p_state,3);
        p_topleftState[i]->p_HLayout->addWidget(p_topleftState[i]->p_num,2);
        p_topleftState[i]->p_HLayout->addWidget(p_topleftState[i]->p_lable,2);
      p_VTopleftLayout->addLayout(p_topleftState[i]->p_HLayout);
      if(i==5){
          QLabel* lable=new QLabel(this);
          lable->setFixedHeight(10);
          lable->setStyleSheet("border-width: 0px;");
          p_VTopleftLayout->addWidget(lable);
      }


    }



    p_toprightwidget=new QWidget(this);
    p_toprightHlable=new QLabel(this);
     p_toprightVlable=new QLabel(this);
    p_toprightPowerlable=new QLabel(this);
     p_toprightWindlable=new QLabel(this);
     p_navigationlable=new QLabel(this);
     p_toprightwidget->setStyleSheet("color: rgb(255, 255, 255);\
                                     border-width: 1.4px;\
                                     border-color: #31b9fb;\
                                     border-bottom-color: #31b9fb;\
                                    background-color: #031830;\
                                     border-style: solid;");

     p_toprightwidget->setFixedSize(200,160);
     p_toprightHlable->setFixedSize(1.4,140);
     p_toprightVlable->setFixedSize(140,1.4);
     p_navigationlable->setFixedSize(1,40);
     p_toprightPowerlable->setStyleSheet("border-width: 0px;\
                                           color: #31b9fb;");


     p_toprightWindlable->setStyleSheet("border-width: 0px;\
                                        color: #31b9fb;");
     p_toprightHlable->setStyleSheet("color: rgb(255, 255, 255);\
                                     border-width: 1.4px;\
                                     border-color: #31b9fb;\
                                     border-bottom-color: #31b9fb;\
                                      background-color: #031830;\
                                     border-style: solid;");
    p_toprightVlable->setStyleSheet("color: rgb(255, 255, 255);\
                                    border-width: 1.4px;\
                                    border-color: #31b9fb;\
                                    border-bottom-color: #31b9fb;\
                                    background-color: #031830;\
                                    border-style: solid;");

     p_navigationlable->setStyleSheet("color: rgb(255, 255, 255);\
                                      border-width: 1px;\
                                      border-color: #31b9fb;\
                                      border-bottom-color: #31b9fb;\
                                      background-color: #031830;\
                                      border-style: solid;");
     p_toprightPowerlable->setText("功率");
     p_toprightWindlable->setText("风速");
     qDebug()<<ui->widget_20->width()<<ui->widget_20->height();

     for(int i=0;i<7;i++){
         p_icon[i]=new QLabel(this);

       p_icon[i]->setMaximumSize(19,19);

        p_icon[i]->hide();
     }
     p_icon[0]->setStyleSheet("border-image: url(:/new/images/images/icon1.png);");

        p_icon[1]->setStyleSheet("border-image: url(:/new/images/images/icon2.png);");
         p_icon[2]->setStyleSheet("border-image: url(:/new/images/images/icon3.png);");
         p_icon[3]->setStyleSheet("border-image: url(:/new/images/images/icon4.png);");
         p_icon[4]->setStyleSheet("border-image: url(:/new/images/images/icon5.png);");
          p_icon[5]->setStyleSheet("border-image: url(:/new/images/images/icon6.png);");
           p_icon[6]->setStyleSheet("border-image: url(:/new/images/images/icon7.png);");

           for(int i=0;i<8;i++){
               p_mapState[i]=new PDMapState;
               p_mapState[i]->p_name=new QLabel(this);
             p_mapState[i]->p_name->setMaximumSize(60,23);
              p_mapState[i]->p_name->setAlignment(Qt::AlignCenter);
             p_mapState[i]->p_name->setStyleSheet("color: #31b9fb;\
                                                  border-width: 1px;\
                                                  border-color: #31b9fb;\
                                                  border-bottom-color: #31b9fb;\
                                                   background-color: #0a446c;\
                                                  border-style: solid;");
             p_mapState[i]->p_name->hide();
             p_mapState[i]->p_name->installEventFilter(this);
           }

           for(int i=0;i<8;i++){
                 p_mapState[i]->p_fengjiIcon=new QLabel(this);
             p_mapState[i]->p_fengjiIcon->setMaximumSize(35,50);

             p_mapState[i]->p_fengjiIcon->setStyleSheet("border-image: url(:/new/images/images/fengji.png);");

             p_mapState[i]->p_fengjiIcon->hide();
           }

           for(int i=0;i<8;i++){
               p_windFieldProgress[i]=new PDWindFieldProgress;
               p_windFieldProgress[i]->p_progress=new QLabel(this);
               p_windFieldProgress[i]->p_num=new QLabel(this);
                p_windFieldProgress[i]->p_num->setMinimumSize(30,18);
             p_windFieldProgress[i]->p_progress->setFixedHeight(18);
              p_windFieldProgress[i]->p_progress->setAlignment(Qt::AlignLeft);

                p_windFieldProgress[i]->p_progress->setStyleSheet("border-image: url(:/images/进度.png);");
              p_windFieldProgress[i]->p_num->setText("50.00");
              p_windFieldProgress[i]->p_num->setStyleSheet("border-width: 0px;\
                                                 color: #31b9fb;");
           //  p_windFieldProgress[i]->p_num->hide();
             //  p_windFieldProgress[i]->p_progress->hide();
           }
            p_windFieldProgress[0]->p_num->setText("47.00");
           p_windFieldProgress[0]->p_progress->setFixedWidth(94);
           p_windFieldProgress[1]->p_num->setText("40.00");
          p_windFieldProgress[1]->p_progress->setFixedWidth(80);
          p_windFieldProgress[2]->p_num->setText("22.00");
         p_windFieldProgress[2]->p_progress->setFixedWidth(44);
         p_windFieldProgress[3]->p_num->setText("35.00");
        p_windFieldProgress[3]->p_progress->setFixedWidth(70);
        p_windFieldProgress[4]->p_num->setText("15.00");
       p_windFieldProgress[4]->p_progress->setFixedWidth(30);
       p_windFieldProgress[5]->p_num->setText("42.00");
      p_windFieldProgress[5]->p_progress->setFixedWidth(84);
      p_windFieldProgress[6]->p_num->setText("7.00");
     p_windFieldProgress[6]->p_progress->setFixedWidth(14);
     p_windFieldProgress[7]->p_num->setText("3.00");
    p_windFieldProgress[7]->p_progress->setFixedWidth(6);

           ui->horizontalLayout_22->addWidget(p_windFieldProgress[0]->p_progress);
           ui->horizontalLayout_22->addWidget(p_windFieldProgress[0]->p_num);
           ui->horizontalLayout_39->addWidget(p_windFieldProgress[1]->p_progress);
           ui->horizontalLayout_39->addWidget(p_windFieldProgress[1]->p_num);
           ui->horizontalLayout_41->addWidget(p_windFieldProgress[2]->p_progress);
           ui->horizontalLayout_41->addWidget(p_windFieldProgress[2]->p_num);
           ui->horizontalLayout_43->addWidget(p_windFieldProgress[3]->p_progress);
             ui->horizontalLayout_43->addWidget(p_windFieldProgress[3]->p_num);
           ui->horizontalLayout_45->addWidget(p_windFieldProgress[4]->p_progress);
           ui->horizontalLayout_45->addWidget(p_windFieldProgress[4]->p_num);
           ui->horizontalLayout_47->addWidget(p_windFieldProgress[5]->p_progress);
           ui->horizontalLayout_47->addWidget(p_windFieldProgress[5]->p_num);
           ui->horizontalLayout_49->addWidget(p_windFieldProgress[6]->p_progress);
           ui->horizontalLayout_49->addWidget(p_windFieldProgress[6]->p_num);
           ui->horizontalLayout_51->addWidget(p_windFieldProgress[7]->p_progress);
           ui->horizontalLayout_51->addWidget(p_windFieldProgress[7]->p_num);
           qDebug()<<p_toprightwidget->width();


           p_mapNums=new PDMapNums;


           p_mapNums->p_widget=new QWidget(this);

           for(int i=0;i<3;i++){
               p_mapNums->p_winds[i]=new QLabel(this);
               p_mapNums->p_powers[i]=new QLabel(this);
               p_mapNums->p_electricitys[i]=new QLabel(this);

               p_mapNums->p_HLayouts[i]=new QHBoxLayout(this);
            p_mapNums->p_HLayouts[i]->setContentsMargins(0,0,0,0);

             p_mapNums->p_HLayouts[i]->setContentsMargins(0,0,0,0);

              p_mapNums->p_HLayouts[i]->setSpacing(0);
               p_mapNums->p_winds[i]->setMinimumSize(35,27);
               p_mapNums->p_powers[i]->setMinimumSize(35,27);
               p_mapNums->p_electricitys[i]->setMinimumSize(35,27);

               p_mapNums->p_winds[i]->setStyleSheet("border-width: 0px;\
                                                     background-color: #236696;");

                       p_mapNums->p_powers[i]->setStyleSheet("border-width: 0px;\
                                                             background-color:#236696;");

                       p_mapNums->p_electricitys[i]->setStyleSheet("border-width: 0px;\
                                                             background-color:#236696;");

                       p_mapNums->p_winds[i]->setAlignment(Qt::AlignCenter);
               p_mapNums->p_electricitys[i]->setAlignment(Qt::AlignCenter);
               p_mapNums->p_powers[i]->setAlignment(Qt::AlignCenter);

                p_mapNums->p_winds[i]->installEventFilter(this);
                 p_mapNums->p_electricitys[i]->installEventFilter(this);
                  p_mapNums->p_powers[i]->installEventFilter(this);

               switch (i) {
               case 0:
                        p_mapNums->p_winds[i]->setMinimumSize(70,27);
                         p_mapNums->p_electricitys[i]->setMinimumSize(70,27);
                          p_mapNums->p_powers[i]->setMinimumSize(70,27);
                       p_mapNums->p_winds[i]->setText("平均风速");
                       p_mapNums->p_electricitys[i]->setText("日发电量");
                       p_mapNums->p_powers[i]->setText("有用功率");

                   break;
               case 1:
                   p_mapNums->p_winds[i]->setStyleSheet("border-width: 0px;\
                                                        background-color:#236696;\
                                                         color: #29CBD2;");

                           p_mapNums->p_powers[i]->setStyleSheet("border-width: 0px;\
                                                                 background-color:#236696;\
                                                                 color:#29CBD2;");

                           p_mapNums->p_electricitys[i]->setStyleSheet("border-width: 0px;\
                                                                       background-color:#236696;\
                                                                 color:#29CBD2;");

                       p_mapNums->p_winds[i]->setText("35.5");
                       p_mapNums->p_electricitys[i]->setText("55.55");
                       p_mapNums->p_powers[i]->setText("88.88");
                   break;
               case 2:
                       p_mapNums->p_winds[i]->setText("m/s");
                       p_mapNums->p_electricitys[i]->setText("万kwh");
                       p_mapNums->p_powers[i]->setText("mw");
                   break;
               default:
                   break;
               }
           }

           p_mapNums->p_HLayouts[0]->addWidget(p_mapNums->p_winds[0]);
            p_mapNums->p_HLayouts[0]->addWidget(p_mapNums->p_winds[1]);
             p_mapNums->p_HLayouts[0]->addWidget(p_mapNums->p_winds[2]);

             p_mapNums->p_HLayouts[1]->addWidget(p_mapNums->p_electricitys[0]);
              p_mapNums->p_HLayouts[1]->addWidget(p_mapNums->p_electricitys[1]);
               p_mapNums->p_HLayouts[1]->addWidget(p_mapNums->p_electricitys[2]);

               p_mapNums->p_HLayouts[2]->addWidget(p_mapNums->p_powers[0]);
                p_mapNums->p_HLayouts[2]->addWidget(p_mapNums->p_powers[1]);
                 p_mapNums->p_HLayouts[2]->addWidget(p_mapNums->p_powers[2]);


           p_mapNums->p_widget->setMinimumSize(150,90);
           p_mapNums->p_VLayout=new QVBoxLayout(p_mapNums->p_widget);
        p_mapNums->p_VLayout->setContentsMargins(0,0,0,0);
         p_mapNums->p_widget->setContentsMargins(0,9,0,0);
         p_mapNums->p_VLayout->setContentsMargins(0,0,0,0);
          p_mapNums->p_VLayout->setContentsMargins(0,0,0,0);
          p_mapNums->p_VLayout->setSpacing(0);
          p_mapNums->p_widget->setStyleSheet("color: rgb(255, 255, 255);\
                                             background-color: #51B8FE;\
                                            ");

            p_mapNums->p_VLayout->addLayout(p_mapNums->p_HLayouts[0]);
              p_mapNums->p_VLayout->addLayout(p_mapNums->p_HLayouts[1]);
                p_mapNums->p_VLayout->addLayout(p_mapNums->p_HLayouts[2]);
        p_mapNums->p_widget->hide();


        p_topMapNumsHide=new QLabel(this);
        p_topMapNumsHide->setMinimumSize(420,50);
      //  p_topMapNumsHide->setStyleSheet(" background-color: #031830;");
        p_topMapNumsHide->installEventFilter(this);

        p_matrixmenu=new PDMatrixmenu;

//风机矩阵top
           p_matrixTop=new PDMatrixTop;

           p_matrixTop->p_widget=new QWidget(this);

        //   p_matrixFengChangUnit->p_widget->setMinimumWidth(this->width()-ui->label_4->width());

           p_matrixTop->p_widget->setContentsMargins(0,0,0,0);

           p_matrixTop->p_widget->setStyleSheet("color: #31B9FB;\
                                                                border-width: 0px;\
                                                                border-color: #31b9fb;\
                                                                border-bottom-color: #31b9fb;\
                                                                   background-color: #031830;\
                                                                border-style: solid;");
         p_matrixTop->p_VLayout=new QVBoxLayout(this);
           p_matrixTop->p_VLayout->setSpacing(0);
           p_matrixTop->p_HLayout=new QHBoxLayout(p_matrixTop->p_widget);
           p_matrixTop->p_HLayout->setSpacing(0);
         //  p_matrixTop->p_HLayout->setContentsMargins(11,11,11,11);
            p_matrixTop->p_HLayout->setContentsMargins(0,0,0,0);


            QLabel * lable=new QLabel(p_matrixTop->p_widget);
            lable->setStyleSheet("color:  #31B9FB;\
                                                      border-width: 0px;\
                                                      border-color: #31b9fb;\
                                                      border-bottom-color: #31b9fb;\
                                                         background-color: #031830;\
                                                      border-style: solid;\
                                                      font-size:14px;\
                                                         font-family:雅黑;");
            lable->setText("国电和风");
            lable->setAlignment(Qt::AlignCenter);
            lable->setMinimumWidth(100);
            for(int i=0;i<3;i++){
                p_matrixTop->p_name[i]=new QLabel(this);
                p_matrixTop->p_name[i]->setStyleSheet("color:  #31B9FB;\
                                                      border-width: 0px;\
                                                      border-color: #31b9fb;\
                                                      border-bottom-color: #31b9fb;\
                                                         background-color: #031830;\
                                                      border-style: solid;\
                                                      font-size:14px;\
                                                         font-family:雅黑;");
           //  p_matrixTop->p_name[i]->setMaximumSize(30,26);//和风字体大小


               p_matrixTop->p_num[i]=new QLabel(this);
               p_matrixTop->p_num[i]->setStyleSheet("color: #33FFFF;\
                                         border-width: 0px;\
                                         border-color: #31b9fb;\
                                         border-bottom-color: #31b9fb;\
                                            background-color: #031830;\
                                         border-style: solid;\
                                         font-size:14px;\
                                            font-family:雅黑;");
              // p_matrixTop->p_num[i]->setMinimumSize(75,33);//和风字体大小
             p_matrixTop->p_num[i]->setMinimumSize(50,26);//和风字体大小


               p_matrixTop->p_unit[i]=new QLabel(this);
               p_matrixTop->p_unit[i]->setStyleSheet("color: #31B9FB;\
                                         border-width: 0px;\
                                         border-color: #31b9fb;\
                                         border-bottom-color: #31b9fb;\
                                            background-color: #031830;\
                                         border-style: solid;\
                                         font-size:14px;\
                                            font-family:雅黑;");
             // p_matrixTop->p_unit[i]->setMinimumSize(45,28);//和风字体大小
            p_matrixTop->p_unit[i]->setMinimumSize(30,26);//和风字体大小
              p_matrixTop->p_unit[i]->setAlignment(Qt::AlignCenter);
          //    p_matrixTop->p_unit[i]->setAlignment(Qt::AlignVCenter);



                 switch (i) {
                 case 0:


                     p_matrixTop->p_HLayout->addWidget(lable,1);
                     p_matrixTop->p_name[i]->setText("装机容量:");
                     p_matrixTop->p_num[i]->setText("");
                       p_matrixTop->p_unit[i]->setText("MW");
                     break;

                 case 1:

                     p_matrixTop->p_name[i]->setText("平均风速:");
                     p_matrixTop->p_num[i]->setText("");
                       p_matrixTop->p_unit[i]->setText("m/s");
                     break;

                 case 2:

                     p_matrixTop->p_name[i]->setText("有公功率:");
                     p_matrixTop->p_num[i]->setText("");
                       p_matrixTop->p_unit[i]->setText("MW");
                     break;

                 case 3:

                     p_matrixTop->p_name[i]->setText("日电量:");
                     p_matrixTop->p_num[i]->setText("");
                       p_matrixTop->p_unit[i]->setText("MWh");
                     break;

                 case 4:

                     p_matrixTop->p_name[i]->setText("月电量:");
                     p_matrixTop->p_num[i]->setText("");
                       p_matrixTop->p_unit[i]->setText("MWh");
                     break;

                 case 5:

                     p_matrixTop->p_name[i]->setText("年电量:");
                     p_matrixTop->p_num[i]->setText("");
                       p_matrixTop->p_unit[i]->setText("MWh");
                     break;


                 case 6:

                   //  p_matrixTop->p_name[i]->setText("负荷率:");
                    // p_matrixTop->p_num[i]->setText("213123.23");
                      // p_matrixTop->p_unit[i]->setText("%");
                     break;


                 default:
                     break;
                 }
                // ui->horizontalLayout_9->addWidget( p_matrixTop->p_name[i],1);
                // ui->horizontalLayout_9->addWidget( p_matrixTop->p_num[i],1);
                // ui->horizontalLayout_9->addWidget( p_matrixTop->p_unit[i],1);
                 p_matrixTop->p_HLayout->addWidget( p_matrixTop->p_name[i],1);
                p_matrixTop->p_HLayout->addWidget( p_matrixTop->p_num[i],1);
                 p_matrixTop->p_HLayout->addWidget( p_matrixTop->p_unit[i],1);

           }
            p_matrixTop->p_SpacerItem=new QSpacerItem(1500, 26 ,QSizePolicy::Expanding,QSizePolicy::Minimum);

           // p_matrixTop->p_lableSpace=new QLabel(this);
           //  p_matrixTop->p_HLayout->addWidget(p_matrixTop->p_SpacerItem);
            p_matrixTop->p_HLayout->addItem(p_matrixTop->p_SpacerItem);

          // ui->horizontalLayout_9->addWidget( p_matrixTop->p_lableSpace,1);

           for(int i=0;i<7;i++){
               p_matrixTop->p_state[i]=new QLabel(this);
             /*  p_matrixTop->p_state[i]->setStyleSheet("color: rgb(255, 255, 255);\
                                         border-width: 0px;\

                                            background-color: #031830;\
                                         border-style: solid;\
                                         font-size:14px;\
                                            font-family:雅黑;");*/
              p_matrixTop->p_state[i]->setMinimumSize(70,26);
              p_matrixTop->p_state[i]->setContentsMargins(0,0,6,0);

              p_matrixTop->p_state[i]->setAlignment(Qt::AlignRight|Qt::AlignVCenter);








              switch (i) {
              case 0:

                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
                   border-image: url(:/new/images/images/矩阵顶部-装机.png);\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("装机:0");
                  break;

              case 1:
                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
                        border-image: url(:/new/images/images/矩阵顶部-并网.png);\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("并网:0");
                  break;

              case 2:
                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
                  border-image: url(:/new/images/images/矩阵顶部-待机.png);\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("待机:0");
                  break;

              case 3:
                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
           border-image: url(:/new/images/images/矩阵顶部-故障.png);\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("故障:0");
                  break;

              case 4:

                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
       border-image: url(:/new/images/images/矩阵顶部-维护.png);\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("维护:0");
                  break;

              case 5:

                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
           border-image: url(:/new/images/images/矩阵顶部-离线.png);\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("离线:0");
                  break;

              case 6:

                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
      border-image: url(:/new/images/images/矩阵顶部-限电.png);\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("限电:0");
                  break;

              case 7:

                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
                                           background-color:#B0973F;\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("停机:0");
                  break;

              case 8:

                  p_matrixTop->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                            border-width: 0px;\
                                            background-color: #B10E7E;\
                  font-size:12px;\
                     font-family:雅黑;");
                       p_matrixTop->p_state[i]->setText("限电:0");
                  break;


              default:
                  break;
              }


                 p_matrixTop->p_HLayout->addWidget( p_matrixTop->p_state[i],1);

               ui->horizontalLayout_9->addWidget(p_matrixTop->p_widget);

           }

           QLabel *S_lable=new QLabel(this);
          // S_lable->setFixedWidth(117);
            S_lable->setFixedWidth(18);
         //  p_matrixTop->p_HLayout->addWidget(S_lable);


 //矩阵风场


                   for(int i=0;i<5;i++){
                    PDMatrixId *matrixId=new PDMatrixId;
                    matrixId->p_id=QString::number(i,10);

                    switch (i) {

                    case 0:
                             matrixId->p_fengjiCount.append(54);
                             matrixId->p_fengjiCount.append(93);
                             matrixId->p_fengjiCount.append(66);
                            matrixId->p_fengjiCount.append(64);
                            matrixId->p_fengjiCount.append(33);
                            matrixId->p_fengjiCount.append(33);
                            matrixId->p_fengjiCount.append(33);
                           matrixId->p_fengjiCount.append(33);

                           matrixId->p_fengjiCount.append(33);
                           matrixId->p_fengjiCount.append(66);
                           matrixId->p_fengjiCount.append(66);

                           matrixId->p_fengjiCount.append(24);
                           matrixId->p_fengjiCount.append(48);

                           matrixId->p_fengjiCount.append(33);
                           matrixId->p_fengjiCount.append(33);


                        matrixId->p_fengchangList.append("兴城风电场");
                         matrixId->p_fengchangList.append("凌海风电场");
                         matrixId->p_fengchangList.append("芳山风电场");
                          matrixId->p_fengchangList.append("北镇风电场");
                           matrixId->p_fengchangList.append("西八千风电场");
                            matrixId->p_fengchangList.append("调兵山风电场");
                             matrixId->p_fengchangList.append("台子风电场");
                              matrixId->p_fengchangList.append("塘坊风电场");

                              matrixId->p_fengchangList.append("郊区风电场");
                               matrixId->p_fengchangList.append("青龙风电场");
                               matrixId->p_fengchangList.append("宝山风电场");

                               matrixId->p_fengchangList.append("万发风电场");
                                matrixId->p_fengchangList.append("永茂风电场");

                      matrixId->p_fengchangList.append("天源风电场");
                   matrixId->p_fengchangList.append("敖伦风电场");

                   pageFengChangCounts.append(matrixId->p_fengchangList.count());

                        break;

                    case 1:
                        matrixId->p_fengjiCount.append(54);
                        matrixId->p_fengjiCount.append(93);
                        matrixId->p_fengjiCount.append(66);
                       matrixId->p_fengjiCount.append(64);
                       matrixId->p_fengjiCount.append(33);
                       matrixId->p_fengjiCount.append(33);
                       matrixId->p_fengjiCount.append(33);
                      matrixId->p_fengjiCount.append(33);

                      matrixId->p_fengchangList.append("兴城风电场");
                       matrixId->p_fengchangList.append("凌海风电场");
                       matrixId->p_fengchangList.append("芳山风电场");
                        matrixId->p_fengchangList.append("北镇风电场");
                         matrixId->p_fengchangList.append("西八千风电场");
                          matrixId->p_fengchangList.append("调兵山风电场");
                           matrixId->p_fengchangList.append("台子风电场");
                            matrixId->p_fengchangList.append("塘坊风电场");

                         pageFengChangCounts.append(matrixId->p_fengchangList.count());

                        break;
                    case 2:
                        matrixId->p_fengjiCount.append(33);
                        matrixId->p_fengjiCount.append(66);
                        matrixId->p_fengjiCount.append(66);
                        matrixId->p_fengchangList.append("郊区风电场");
                         matrixId->p_fengchangList.append("青龙风电场");
                         matrixId->p_fengchangList.append("宝山风电场");
                         pageFengChangCounts.append(matrixId->p_fengchangList.count());
                        break;
                    case 3:
                        matrixId->p_fengjiCount.append(24);
                        matrixId->p_fengjiCount.append(48);
                        matrixId->p_fengchangList.append("万发风电场");
                         matrixId->p_fengchangList.append("永茂风电场");
                        pageFengChangCounts.append(matrixId->p_fengchangList.count());

                        break;
                    case 4:


                        matrixId->p_fengjiCount.append(33);
                        matrixId->p_fengjiCount.append(33);
                       matrixId->p_fengchangList.append("天源风电场");
                    matrixId->p_fengchangList.append("敖伦风电场");
                      pageFengChangCounts.append(matrixId->p_fengchangList.count());
                        break;

                    default:
                        break;
                    }
                    p_matrixId.append(matrixId);
                   }

                   this->setMatrixFengchang();

                   ui->stackedWidget_2->setCurrentIndex(0);



 //风机图标样式stringlist
              QString str1,str2,str3,str4,str5,str6,str7,str8;

              str1="color: #030708;\
                                   border-width: 1px;\
                                   border-color: #0A5CA1;\
                                   border-bottom-color: #0A5CA1;\
                                  background-color:#080E21;\
                                   border-style: solid;\
                                   font-size:12px;\
                                   font-family:雅黑;";

                str2="color:#030708;\
                                        border-width: 1px;\
                                        border-color: #0A5CA1;\
                                        border-bottom-color: #0A5CA1;\
                                      background-image: url(:/new/images/images/矩阵-并网.png);\
                                        border-style: solid;\
                                        font-size:12px;\
                                        font-family:雅黑;";


              str3="color:#030708;\
                                      border-width: 1px;\
                                      border-color: #0A5CA1;\
                                      border-bottom-color: #0A5CA1;\
                                    background-image: url(:/new/images/images/矩阵-待机.png);\
                                      border-style: solid;\
                                      font-size:12px;\
                                      font-family:雅黑;";

            str4="color:#030708;\
                                    border-width: 1px;\
                                    border-color: #0A5CA1;\
                                    border-bottom-color: #0A5CA1;\
                                  background-image: url(:/new/images/images/矩阵-故障.png);\
                                    border-style: solid;\
                                    font-size:12px;\
                                    font-family:雅黑;";

             str5="color:#030708;\
                                     border-width: 1px;\
                                     border-color: #0A5CA1;\
                                     border-bottom-color: #0A5CA1;\
                                   background-image: url(:/new/images/images/矩阵-维护.png);\
                                     border-style: solid;\
                                     font-size:12px;\
                                     font-family:雅黑;";

             str6="color:#030708;\
                                     border-width: 1px;\
                                     border-color: #0A5CA1;\
                                     border-bottom-color: #0A5CA1;\
                                   background-image: url(:/new/images/images/矩阵-离线.png);\
                                     border-style: solid;\
                                     font-size:12px;\
                                     font-family:雅黑;";

              str7="color:#030708;\
                                      border-width: 1px;\
                                      border-color: #0A5CA1;\
                                      border-bottom-color: #0A5CA1;\
                                    background-image: url(:/new/images/images/矩阵-限电.png);\
                                      border-style: solid;\
                                      font-size:12px;\
                                      font-family:雅黑;";


              str8="color:#030708;\
                                      border-width: 1px;\
                                      border-color: #0A5CA1;\
                                      border-bottom-color: #0A5CA1;\
                                    background-image: url(:/new/images/images/矩阵顶部-经过.png);\
                                      border-style: solid;\
                                      font-size:12px;\
                                      font-family:雅黑;";

            FJStateList.append(str1);
            FJStateList.append(str2);
            FJStateList.append(str3);
            FJStateList.append(str4);
            FJStateList.append(str5);
            FJStateList.append(str6);
            FJStateList.append(str7);
             FJStateList.append(str8);




}

void MainWindow::setStates_Host()
{
    for(int i=0;i<10;i++){
        p_lable[i]=new QLabel(this);
        p_lable[i]->setStyleSheet("color: rgb(255, 255, 255);\
                                  border-width: 1.4px;\
                                  border-color: #31b9fb;\
                                  border-bottom-color: #31b9fb;\
                                     background-color: #031830;\
                                  border-style: solid;");
        p_lable[i]->setMinimumSize(60,30);
        p_lable[i]->hide();
    }



    for(int i=0;i<7;i++){


              p_state[i]=new PDState;
         p_state[i]->p_widget=new QWidget(this);
         p_state[i]->p_state=new QLabel(this);
         p_state[i]->p_num=new QLabel(this);
         p_state[i]->p_lable=new QLabel(this);
         p_state[i]->p_icon=new QLabel(this);
          p_state[i]->p_num->setAlignment(Qt::AlignCenter);
          p_state[i]->p_lable->setAlignment(Qt::AlignCenter);
           p_state[i]->p_state->setAlignment(Qt::AlignCenter);
        p_state[i]->p_HLayout=new QHBoxLayout(p_state[i]->p_widget);
        p_state[i]->p_widget->setFixedSize(200,35);
        p_state[i]->p_widget->setContentsMargins(0,0,0,0);
         p_state[i]->p_HLayout->setSpacing(0);
        p_state[i]->p_widget->setStyleSheet("color: rgb(255, 255, 255);\
                                            border-width: 1.4px;\
                                            border-color: #31b9fb;\
                                            border-bottom-color: #31b9fb;\
                                            border-style: solid;\
                                            background-color: #031830;\
                                           ");

        p_state[i]->p_state->setStyleSheet("border-width: 0px;\
                                           color: #31b9fb;");
         p_state[i]->p_num->setStyleSheet("border-width: 0px;\
                                          color: #31b9fb;");
          p_state[i]->p_lable->setStyleSheet("border-width: 0px;\
                                              color: #31b9fb;");
          p_state[i]->p_icon->setStyleSheet("border-width: 0px;");

        p_state[i]->p_state->setText("接入");
        p_state[i]->p_num->setText("1234");
        p_state[i]->p_lable->setText("台");
      //  p_state[i]->p_icon->setFixedSize(30,30);
         p_state[i]->p_HLayout->addWidget(p_state[i]->p_icon,1);
        p_state[i]->p_HLayout->addWidget(p_state[i]->p_state,1);
        p_state[i]->p_HLayout->addWidget(p_state[i]->p_num,1);
        p_state[i]->p_HLayout->addWidget(p_state[i]->p_lable,1);

    }

 /*   p_state[0]->p_icon->setStyleSheet("border-image: url(:/new/images/images/icon1.png);\
                                      border-width: 0px;\
                                      ");
     p_state[1]->p_icon->setStyleSheet("background-image: url(:/new/images/images/icon1.png);");
      p_state[2]->p_icon->setStyleSheet("background-image: url(:/new/images/images/icon1.png);\
                                        border-width: 0px;");
      p_state[3]->p_icon->setStyleSheet("border-image: url(:/new/images/images/icon4png);");
      p_state[4]->p_icon->setStyleSheet("image: url(:/new/images/images/icon5.png);\
                                        border-width: 0px;");
       p_state[5]->p_icon->setStyleSheet("border-image: url(:/new/images/images/icon6.png);");
        p_state[6]->p_icon->setStyleSheet("border-image: url(:/new/images/images/icon7.png);");

*/

    p_topleftwidget=new QWidget(this);
    p_VTopleftLayout=new QVBoxLayout(p_topleftwidget);
    p_VTopleftLayout->setSpacing(0);
    p_topleftwidget->setContentsMargins(7,0,0,0);
   p_topleftwidget->setStyleSheet("color: rgb(255, 255, 255);\
                                  border-width: 1.4px;\
                                  border-color: #31b9fb;\
                                  border-bottom-color: #31b9fb;\
                                   background-color: #031830;\
                                  border-style: solid;");

    p_topleftlable=new QLabel(this);
    p_topleftlable->setFixedSize(190,1.4);
    p_topleftlable->setStyleSheet("color: rgb(255, 255, 255);\
                                  border-width: 1.4px;\
                                  border-color: #31b9fb;\
                                  border-bottom-color: #31b9fb;\
                                    background-color: #031830;\
                                  border-style: solid;");

    p_topleftwidget->setFixedSize(200,200);
    for(int i=0;i<8;i++){
        p_topleftState[i]=new PDTopLeftState;

       p_topleftState[i]->p_state=new QLabel(this);
        p_topleftState[i]->p_num=new QLabel(this);
        p_topleftState[i]->p_lable=new QLabel(this);
        p_topleftState[i]->p_HLayout=new QHBoxLayout(this);
        p_topleftState[i]->p_state->setAlignment(Qt::AlignLeft);
        p_topleftState[i]->p_state->setAlignment(Qt::AlignVCenter);
        p_topleftState[i]->p_num->setAlignment(Qt::AlignCenter);
        //p_topleftState[i]->p_num->setAlignment(Qt::AlignVCenter);
         p_topleftState[i]->p_lable->setAlignment(Qt::AlignCenter);
         p_topleftState[i]->p_HLayout->setSpacing(0);
         p_topleftState[i]->p_state->setStyleSheet("border-width: 0px;\
                                                   color: #31b9fb;");
          p_topleftState[i]->p_num->setStyleSheet("border-width: 0px;\
                                                  color: #31b9fb;");
           p_topleftState[i]->p_lable->setStyleSheet("border-width: 0px;\
                                                     color: #31b9fb;");
        p_topleftState[i]->p_state->setText("接入");
        p_topleftState[i]->p_num->setText("7777.5");
       p_topleftState[i]->p_lable->setText("MW");
       p_topleftState[i]->p_HLayout->addWidget(p_topleftState[i]->p_state,3);
        p_topleftState[i]->p_HLayout->addWidget(p_topleftState[i]->p_num,2);
        p_topleftState[i]->p_HLayout->addWidget(p_topleftState[i]->p_lable,2);
      p_VTopleftLayout->addLayout(p_topleftState[i]->p_HLayout);
      if(i==5){
          QLabel* lable=new QLabel(this);
          lable->setFixedHeight(10);
          lable->setStyleSheet("border-width: 0px;");
          p_VTopleftLayout->addWidget(lable);
      }


    }



    p_toprightwidget=new QWidget(this);
    p_toprightHlable=new QLabel(this);
     p_toprightVlable=new QLabel(this);
    p_toprightPowerlable=new QLabel(this);
     p_toprightWindlable=new QLabel(this);
     p_navigationlable=new QLabel(this);
     p_toprightwidget->setStyleSheet("color: rgb(255, 255, 255);\
                                     border-width: 1.4px;\
                                     border-color: #31b9fb;\
                                     border-bottom-color: #31b9fb;\
                                    background-color: #031830;\
                                     border-style: solid;");

     p_toprightwidget->setFixedSize(200,160);
     p_toprightHlable->setFixedSize(1.4,140);
     p_toprightVlable->setFixedSize(140,1.4);
     p_navigationlable->setFixedSize(1,40);
     p_toprightPowerlable->setStyleSheet("border-width: 0px;\
                                           color: #31b9fb;");


     p_toprightWindlable->setStyleSheet("border-width: 0px;\
                                        color: #31b9fb;");
     p_toprightHlable->setStyleSheet("color: rgb(255, 255, 255);\
                                     border-width: 1.4px;\
                                     border-color: #31b9fb;\
                                     border-bottom-color: #31b9fb;\
                                      background-color: #031830;\
                                     border-style: solid;");
    p_toprightVlable->setStyleSheet("color: rgb(255, 255, 255);\
                                    border-width: 1.4px;\
                                    border-color: #31b9fb;\
                                    border-bottom-color: #31b9fb;\
                                    background-color: #031830;\
                                    border-style: solid;");

     p_navigationlable->setStyleSheet("color: rgb(255, 255, 255);\
                                      border-width: 1px;\
                                      border-color: #31b9fb;\
                                      border-bottom-color: #31b9fb;\
                                      background-color: #031830;\
                                      border-style: solid;");
     p_toprightPowerlable->setText("功率");
     p_toprightWindlable->setText("风速");
     qDebug()<<ui->widget_20->width()<<ui->widget_20->height();

     for(int i=0;i<7;i++){
         p_icon[i]=new QLabel(this);

       p_icon[i]->setMaximumSize(19,19);

        p_icon[i]->hide();
     }
     p_icon[0]->setStyleSheet("border-image: url(:/new/images/images/icon1.png);");

        p_icon[1]->setStyleSheet("border-image: url(:/new/images/images/icon2.png);");
         p_icon[2]->setStyleSheet("border-image: url(:/new/images/images/icon3.png);");
         p_icon[3]->setStyleSheet("border-image: url(:/new/images/images/icon4.png);");
         p_icon[4]->setStyleSheet("border-image: url(:/new/images/images/icon5.png);");
          p_icon[5]->setStyleSheet("border-image: url(:/new/images/images/icon6.png);");
           p_icon[6]->setStyleSheet("border-image: url(:/new/images/images/icon7.png);");

           for(int i=0;i<8;i++){
               p_mapState[i]=new PDMapState;
               p_mapState[i]->p_name=new QLabel(this);
             p_mapState[i]->p_name->setMaximumSize(60,23);
              p_mapState[i]->p_name->setAlignment(Qt::AlignCenter);
             p_mapState[i]->p_name->setStyleSheet("color: #31b9fb;\
                                                  border-width: 1px;\
                                                  border-color: #31b9fb;\
                                                  border-bottom-color: #31b9fb;\
                                                   background-color: #0a446c;\
                                                  border-style: solid;");
             p_mapState[i]->p_name->hide();
             p_mapState[i]->p_name->installEventFilter(this);
           }

           for(int i=0;i<8;i++){
                 p_mapState[i]->p_fengjiIcon=new QLabel(this);
             p_mapState[i]->p_fengjiIcon->setMaximumSize(35,50);

             p_mapState[i]->p_fengjiIcon->setStyleSheet("border-image: url(:/new/images/images/fengji.png);");

             p_mapState[i]->p_fengjiIcon->hide();
           }

           p_mapNums=new PDMapNums;


           p_mapNums->p_widget=new QWidget(this);

           for(int i=0;i<3;i++){
               p_mapNums->p_winds[i]=new QLabel(this);
               p_mapNums->p_powers[i]=new QLabel(this);
               p_mapNums->p_electricitys[i]=new QLabel(this);

               p_mapNums->p_HLayouts[i]=new QHBoxLayout(this);
            p_mapNums->p_HLayouts[i]->setContentsMargins(0,0,0,0);

             p_mapNums->p_HLayouts[i]->setContentsMargins(0,0,0,0);

              p_mapNums->p_HLayouts[i]->setSpacing(0);
               p_mapNums->p_winds[i]->setMinimumSize(35,27);
               p_mapNums->p_powers[i]->setMinimumSize(35,27);
               p_mapNums->p_electricitys[i]->setMinimumSize(35,27);

               p_mapNums->p_winds[i]->setStyleSheet("border-width: 0px;\
                                                     background-color: #236696;");

                       p_mapNums->p_powers[i]->setStyleSheet("border-width: 0px;\
                                                             background-color:#236696;");

                       p_mapNums->p_electricitys[i]->setStyleSheet("border-width: 0px;\
                                                             background-color:#236696;");

                       p_mapNums->p_winds[i]->setAlignment(Qt::AlignCenter);
               p_mapNums->p_electricitys[i]->setAlignment(Qt::AlignCenter);
               p_mapNums->p_powers[i]->setAlignment(Qt::AlignCenter);

                p_mapNums->p_winds[i]->installEventFilter(this);
                 p_mapNums->p_electricitys[i]->installEventFilter(this);
                  p_mapNums->p_powers[i]->installEventFilter(this);

               switch (i) {
               case 0:
                        p_mapNums->p_winds[i]->setMinimumSize(70,27);
                         p_mapNums->p_electricitys[i]->setMinimumSize(70,27);
                          p_mapNums->p_powers[i]->setMinimumSize(70,27);
                       p_mapNums->p_winds[i]->setText("平均风速");
                       p_mapNums->p_electricitys[i]->setText("日发电量");
                       p_mapNums->p_powers[i]->setText("有用功率");

                   break;
               case 1:
                   p_mapNums->p_winds[i]->setStyleSheet("border-width: 0px;\
                                                        background-color:#236696;\
                                                         color: #29CBD2;");

                           p_mapNums->p_powers[i]->setStyleSheet("border-width: 0px;\
                                                                 background-color:#236696;\
                                                                 color:#29CBD2;");

                           p_mapNums->p_electricitys[i]->setStyleSheet("border-width: 0px;\
                                                                       background-color:#236696;\
                                                                 color:#29CBD2;");

                       p_mapNums->p_winds[i]->setText("35.5");
                       p_mapNums->p_electricitys[i]->setText("55.55");
                       p_mapNums->p_powers[i]->setText("88.88");
                   break;
               case 2:
                       p_mapNums->p_winds[i]->setText("m/s");
                       p_mapNums->p_electricitys[i]->setText("万kwh");
                       p_mapNums->p_powers[i]->setText("mw");
                   break;
               default:
                   break;
               }
           }

           p_mapNums->p_HLayouts[0]->addWidget(p_mapNums->p_winds[0]);
            p_mapNums->p_HLayouts[0]->addWidget(p_mapNums->p_winds[1]);
             p_mapNums->p_HLayouts[0]->addWidget(p_mapNums->p_winds[2]);

             p_mapNums->p_HLayouts[1]->addWidget(p_mapNums->p_electricitys[0]);
              p_mapNums->p_HLayouts[1]->addWidget(p_mapNums->p_electricitys[1]);
               p_mapNums->p_HLayouts[1]->addWidget(p_mapNums->p_electricitys[2]);

               p_mapNums->p_HLayouts[2]->addWidget(p_mapNums->p_powers[0]);
                p_mapNums->p_HLayouts[2]->addWidget(p_mapNums->p_powers[1]);
                 p_mapNums->p_HLayouts[2]->addWidget(p_mapNums->p_powers[2]);


           p_mapNums->p_widget->setMinimumSize(150,90);
           p_mapNums->p_VLayout=new QVBoxLayout(p_mapNums->p_widget);
        p_mapNums->p_VLayout->setContentsMargins(0,0,0,0);
         p_mapNums->p_widget->setContentsMargins(0,9,0,0);
         p_mapNums->p_VLayout->setContentsMargins(0,0,0,0);
          p_mapNums->p_VLayout->setContentsMargins(0,0,0,0);
          p_mapNums->p_VLayout->setSpacing(0);
          p_mapNums->p_widget->setStyleSheet("color: rgb(255, 255, 255);\
                                             background-color: #51B8FE;\
                                            ");

            p_mapNums->p_VLayout->addLayout(p_mapNums->p_HLayouts[0]);
              p_mapNums->p_VLayout->addLayout(p_mapNums->p_HLayouts[1]);
                p_mapNums->p_VLayout->addLayout(p_mapNums->p_HLayouts[2]);
        p_mapNums->p_widget->hide();


}

void MainWindow::setStates_Matrix(int index)
{





}

void MainWindow::setMatrixFengchang()
{

    ui->scrollArea->AdjustToContentsOnFirstShow;
    for(int index=0;index<5;index++){


        int fengChang_count=p_matrixId.at(index)->p_fengchangList.count();
        p_verticalSpacerMatrix=new QSpacerItem(2, this->height(), QSizePolicy::Minimum, QSizePolicy::Expanding);
      for(int i=0;i<fengChang_count;i++){
       //   qDebug()<<"fengindex"<<" "<<i<<endl;
          int fengJi_count=p_matrixId.at(index)->p_fengjiCount.at(i);

        //  QLabel *lable=new QLabel(this);
         // lable->setMinimumHeight(150);

          PDMatrixFengChang * p_matrixFengChangUnit=new PDMatrixFengChang;



          p_matrixFengChangUnit->p_widget=new QWidget(this);

       //   p_matrixFengChangUnit->p_widget->setMinimumWidth(this->width()-ui->label_4->width());

          p_matrixFengChangUnit->p_widget->setContentsMargins(0,0,0,0);

          p_matrixFengChangUnit->p_widget->setStyleSheet("color: #31B9FB;\
                                                               border-width: 0px;\
                                                               border-color: #31b9fb;\
                                                               border-bottom-color: #31b9fb;\
                                                                  background-color: #031830;\
                                                               border-style: solid;");
        p_matrixFengChangUnit->p_VLayout=new QVBoxLayout(this);
          p_matrixFengChangUnit->p_VLayout->setSpacing(0);
          p_matrixFengChangUnit->p_HLayout=new QHBoxLayout(p_matrixFengChangUnit->p_widget);
          p_matrixFengChangUnit->p_HLayout->setSpacing(0);
          p_matrixFengChangUnit->p_HLayout->setContentsMargins(11,11,11,11);
           p_matrixFengChangUnit->p_HLayout->setContentsMargins(0,0,0,0);
       //  p_matrixFengChangUnit->p_VLayout->addLayout(p_matrixFengChangUnit->p_HLayout);


           p_matrixFengChangUnit->p_gridLayout=new QGridLayout(this);
           p_matrixFengChangUnit->p_gridLayout->setSpacing(0);

             p_matrixFengChangUnit->p_widget->setLayout(p_matrixFengChangUnit->p_HLayout);

        // p_matrixFengChangUnit->p_VLayout->addLayout(p_matrixFengChangUnit->p_gridLayout);
        //   QFont font;
      //     font.setPointSize(12);
        // font3.setFamily(("ADMUI3lg"));
       // font.setFamily(("雅黑"));

           p_matrixFengChangUnit->p_fengChang=new QLabel(this);
          p_matrixFengChangUnit->p_fengChang->setStyleSheet("color: #FBFDFB;\
                                                            border-width: 0px;\
                                                            border-color: #31b9fb;\
                                                            border-bottom-color: #31b9fb;\
                                                               background-color: #1F5776;\
                                                            border-style: solid;\
                                                            font-size:14px;\
                                                            font-family:雅黑;");

           p_matrixFengChangUnit->p_fengChang->setMinimumSize(100,32);

           p_matrixFengChangUnit->p_fengChang->setAlignment(Qt::AlignCenter);
       //    p_matrixFengChangUnit->p_fengChang->setFont(font);

            p_matrixFengChangUnit->p_HLayout->addWidget( p_matrixFengChangUnit->p_fengChang);

         /* QStringList list;
              foreach (PDMatrixId *item, p_matrixId ) {

                   foreach (QString str, item->p_fengchangList ){
                       list.append(str);
                   }
              }*/

      p_matrixFengChangUnit->p_fengChang->setText(p_matrixId.at(index)->p_fengchangList.at(i));

         //风机

       int j=0;
       QString s_fengji,s_fengsu,s_dianliang,s_str;
          for(int i=0;i<fengJi_count;i++){

              s_fengji="1A01";
              s_fengsu="30m/s";
              s_dianliang="1232.00kw";

               s_str=QObject::tr("<font size=5 ><b>%1</b></font>").arg(s_fengji)+
                        QObject::tr("<br />")+
                       QObject::tr("<font font   size=3>%1</font>").arg(s_fengsu)+
                       QObject::tr("<br />")+
                        QObject::tr("<font font  size=3>%1</font>").arg(s_dianliang);
              QLabel *fengji=new QLabel(this);
             QString style="color:#030708;\
                     border-width: 1px;\
                     border-color: #0A5CA1;\
                     border-bottom-color: #0A5CA1;\
                   background-image: url(:/new/images/images/矩阵-离线.png);\
                     border-style: solid;\
                     font-size:12px;\
                     font-family:雅黑;";

              fengji->setStyleSheet(style);



              fengji->setAlignment(Qt::AlignRight|Qt::AlignRight);

              fengji->setMinimumSize(95,49);


           //   QFont font;
             // font.setBold(true);
            //  font.setPointSize(10);
          // font.setFamily(("ADMUI3lg"));
          // font.setFamily(("雅黑"));
           //fengji->setFont(font);

           //  fengji->setText(s_str);

              if(i%13==0&&i>12){
                  j++;
                  //qDebug()<<i<<"  j++"<<j;

              }

              if(i<12){
                  p_matrixFengChangUnit->p_gridLayout->addWidget(fengji,j,i);
              }
              else{
                  p_matrixFengChangUnit->p_gridLayout->addWidget(fengji,j,i-j*13);
              }



              fengji->installEventFilter(this);
              p_matrixFengChangUnit->v_fengji.append(fengji);
              p_matrixFengChangUnit->currentStyles.append(style);

            //  delete fengji;
          }

        //     p_matrixFengChangUnit->p_gridLayout->addWidget(lable,0,0);






        for(int i=0;i<3;i++){
            p_matrixFengChangUnit->p_name[i]=new QLabel(this);
            p_matrixFengChangUnit->p_name[i]->setStyleSheet("color:  #31B9FB;\
                                      border-width: 0px;\
                                      border-color: #31b9fb;\
                                      border-bottom-color: #31b9fb;\
                                         background-color: #031830;\
                                      border-style: solid;\
                                      font-size:14px;\
                                         font-family:雅黑;");
        //  p_matrixFengChangUnit->p_name[i]->setMinimumSize(65,26);
    //    p_matrixFengChangUnit->p_name[i]->setMinimumSize(65,26);
         //   p_matrixFengChangUnit->p_name[i]->setFixedSize(p_matrixTop->p_num[i]->size());
            p_matrixFengChangUnit->p_num[i]=new QLabel(this);
            p_matrixFengChangUnit->p_num[i]->setStyleSheet("color: #33FFFF;\
                                      border-width: 0px;\
                                      border-color: #31b9fb;\
                                      border-bottom-color: #31b9fb;\
                                         background-color: #031830;\
                                      border-style: solid;\
                                      font-size:14px;\
                                         font-family:雅黑;");
          // p_matrixFengChangUnit->p_num[i]->setMinimumSize(75,26);
           p_matrixFengChangUnit->p_num[i]->setMinimumSize(50,26);

           // p_matrixFengChangUnit->p_num[i]->setFixedSize(p_matrixTop->p_num[i]->size());

            p_matrixFengChangUnit->p_unit[i]=new QLabel(this);
            p_matrixFengChangUnit->p_unit[i]->setStyleSheet("color: #31B9FB;\
                                      border-width: 0px;\
                                      border-color: #31b9fb;\
                                      border-bottom-color: #31b9fb;\
                                         background-color: #031830;\
                                      border-style: solid;\
                                      font-size:14px;\
                                      font-family:雅黑;");

          //  p_matrixFengChangUnit->p_unit[i]->setFixedSize(p_matrixTop->p_unit[i]->size());
         //  p_matrixFengChangUnit->p_unit[i]->setMinimumSize(45,26);
            p_matrixFengChangUnit->p_unit[i]->setMinimumSize(30,26);
        //     p_matrixFengChangUnit->p_unit[i]->setAlignment(Qt::AlignLeft);
             p_matrixFengChangUnit->p_unit[i]->setAlignment(Qt::AlignCenter);

            //  p_matrixFengChangUnit->p_unit[i]->setAlignment(Qt::AlignLeft);
             //  p_matrixFengChangUnit->p_unit[i]->setAlignment(Qt::AlignHCenter);

              switch (i) {
              case 0:

                  p_matrixFengChangUnit->p_name[i]->setText("装机容量:");
                  p_matrixFengChangUnit->p_num[i]->setText("");
                    p_matrixFengChangUnit->p_unit[i]->setText("MW");
                  break;

              case 1:

                  p_matrixFengChangUnit->p_name[i]->setText("平均风速:");
                  p_matrixFengChangUnit->p_num[i]->setText("");
                    p_matrixFengChangUnit->p_unit[i]->setText("m/s");
                  break;

              case 2:

                  p_matrixFengChangUnit->p_name[i]->setText("有功功率:");
                  p_matrixFengChangUnit->p_num[i]->setText("");
                    p_matrixFengChangUnit->p_unit[i]->setText("MW");
                  break;

              case 3:

                  p_matrixFengChangUnit->p_name[i]->setText("日电量:");
                  p_matrixFengChangUnit->p_num[i]->setText("");
                    p_matrixFengChangUnit->p_unit[i]->setText("MWh");
                  break;

              case 4:

                  p_matrixFengChangUnit->p_name[i]->setText("月电量:");
                  p_matrixFengChangUnit->p_num[i]->setText("");
                    p_matrixFengChangUnit->p_unit[i]->setText("MWh");
                  break;

              case 5:

                  p_matrixFengChangUnit->p_name[i]->setText("年电量:");
                  p_matrixFengChangUnit->p_num[i]->setText("");
                    p_matrixFengChangUnit->p_unit[i]->setText("MWh");
                  break;


              case 6:

                 /* p_matrixFengChangUnit->p_name[i]->setText("负荷率:");
                  p_matrixFengChangUnit->p_num[i]->setText("213123.23");
                    p_matrixFengChangUnit->p_unit[i]->setText("%");
                  break;*/


              default:
                  break;
              }
             p_matrixFengChangUnit->p_HLayout->addWidget( p_matrixFengChangUnit->p_name[i],1);
              p_matrixFengChangUnit->p_HLayout->addWidget( p_matrixFengChangUnit->p_num[i],1);
              p_matrixFengChangUnit->p_HLayout->addWidget( p_matrixFengChangUnit->p_unit[i],1);

        }

        p_matrixFengChangUnit->p_widget->setContentsMargins(0,0,0,0);
        p_matrixFengChangUnit->p_HLayout->setSpacing(0);
        p_matrixFengChangUnit->p_VLayout->setSpacing(0);


        p_matrixFengChangUnit->p_fengChang->installEventFilter(this);
        v_matrixFengChang.append(p_matrixFengChangUnit);

        p_matrixFengChangUnit->p_SpacerItem=new QSpacerItem(1200, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);;

     // p_matrixFengChangUnit->p_SpacerItem->setGeometry(p_matrixTop->p_lableSpace->geometry());
        p_matrixFengChangUnit->p_HLayout->addItem(p_matrixFengChangUnit->p_SpacerItem);
        for(int i=0;i<7;i++){
            p_matrixFengChangUnit->p_state[i]=new QLabel(this);
            p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: rgb(255, 255, 255);\
                                      border-width: 0px;\
                                      border-color: #31b9fb;\
                                      border-bottom-color: #31b9fb;\
                                         background-color: #031830;\
                                      border-style: solid;\
                                       font-size:12px;\
                                      font-family:雅黑;");
           p_matrixFengChangUnit->p_state[i]->setMinimumSize(35,26);
            p_matrixFengChangUnit->p_state[i]->setAlignment(Qt::AlignCenter);






           switch (i) {
           case 0:

               p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 1px;\
                                         background-color: #080E21;\
               border-color: #1F1D1D;\
               border-bottom-color: #1F1D1D;\
                                         font-size:15px;\
                                        font-family:雅黑;");

                   // p_matrixFengChangUnit->p_state[i]->setText(QString::number(fengJi_count,10));
           p_matrixFengChangUnit->p_state[i]->setText(QString::number(0,10));
               break;

           case 1:
               p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 1px;\
                                         background-color: #367935;\
                                                font-size:15px;\
                                                border-color: #1F1D1D;\
                                                border-bottom-color: #1F1D1D;\
                                          font-family:雅黑;");
                    p_matrixFengChangUnit->p_state[i]->setText("0");
               break;

           case 2:
               p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 1px;\
                                         background-color: #60CB5E;\
               border-color: #1F1D1D;\
               border-bottom-color: #1F1D1D;\
                                           font-size:15px;\
                                              font-family:雅黑;");

                    p_matrixFengChangUnit->p_state[i]->setText("0");
               break;

           case 3:
               p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 1px;\
                                         background-color: #CB2020;\
               border-color: #1F1D1D;\
               border-bottom-color: #1F1D1D;\
               font-size:15px;\
                  font-family:雅黑;");
                    p_matrixFengChangUnit->p_state[i]->setText("0");
               break;

           case 4:

               p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 1px;\
                                        background-color: #FF7800;\
               border-color: #1F1D1D;\
               border-bottom-color: #1F1D1D;\
               font-size:15px;\
                  font-family:雅黑;");
                    p_matrixFengChangUnit->p_state[i]->setText("0");
               break;

           case 5:

               p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 1px;\
                                        background-color: #818D95;\
               border-color: #1F1D1D;\
               border-bottom-color: #1F1D1D;\
               font-size:15px;\
                  font-family:雅黑;");
                    p_matrixFengChangUnit->p_state[i]->setText(QString::number(0,10));
               break;

           case 6:

               p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 1px;\
                                       background-color: #B10E7E;\
               border-color: #1F1D1D;\
               border-bottom-color: #1F1D1D;\
               font-size:15px;\
                  font-family:雅黑;");
                    p_matrixFengChangUnit->p_state[i]->setText("0");
               break;

           case 7:

              /* p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 0px;\
                                        background-color:#B0973F;\
               font-size:12px;\
                  font-family:雅黑;");
                    p_matrixFengChangUnit->p_state[i]->setText("256");
               break;*/

           case 8:

            /*   p_matrixFengChangUnit->p_state[i]->setStyleSheet("color: #FBFDFB;\
                                         border-width: 0px;\
                                         background-color: #B10E7E;\
               font-size:12px;\
                  font-family:雅黑;");
                    p_matrixFengChangUnit->p_state[i]->setText("256");
               break;*/


           default:
               break;
           }


              p_matrixFengChangUnit->p_HLayout->addWidget( p_matrixFengChangUnit->p_state[i]);
}

        switch (index) {
        case 0:
            ui->vLayoutStacke2_1->addWidget(p_matrixFengChangUnit->p_widget);
            ui->vLayoutStacke2_1->addLayout(p_matrixFengChangUnit->p_gridLayout);
            break;
        case 1:
            ui->vLayoutStacke2_2->addWidget(p_matrixFengChangUnit->p_widget);
            ui->vLayoutStacke2_2->addLayout(p_matrixFengChangUnit->p_gridLayout);
            break;
        case 2:
            ui->vLayoutStacke2_3->addWidget(p_matrixFengChangUnit->p_widget);
            ui->vLayoutStacke2_3->addLayout(p_matrixFengChangUnit->p_gridLayout);
            break;

        case 3:
            ui->vLayoutStacke2_4->addWidget(p_matrixFengChangUnit->p_widget);
            ui->vLayoutStacke2_4->addLayout(p_matrixFengChangUnit->p_gridLayout);
            break;
        case 4:
            ui->vLayoutStacke2_5->addWidget(p_matrixFengChangUnit->p_widget);
            ui->vLayoutStacke2_5->addLayout(p_matrixFengChangUnit->p_gridLayout);
            break;
        default:
            break;
        }





    //   ui->listWidget->addScrollBarWidget(p_matrixFengChangUnit->p_widget,Qt::AlignLeft);






         //  delete p_matrixFengChangUnit;

      }

      switch (index) {
      case 0:
          ui->vLayoutStacke2_1->addItem(p_verticalSpacerMatrix);
          ui->vLayoutStacke2_1->setSpacing(0);
          break;

      case 1:
          ui->vLayoutStacke2_2->addItem(p_verticalSpacerMatrix);
          ui->vLayoutStacke2_2->setSpacing(0);
          break;
      case 2:
          ui->vLayoutStacke2_3->addItem(p_verticalSpacerMatrix);
          ui->vLayoutStacke2_3->setSpacing(0);
          break;
      case 3:
          ui->vLayoutStacke2_4->addItem(p_verticalSpacerMatrix);
          ui->vLayoutStacke2_4->setSpacing(0);
          break;
      case 4:
          ui->vLayoutStacke2_5->addItem(p_verticalSpacerMatrix);
          ui->vLayoutStacke2_5->setSpacing(0);
          break;

      default:
          break;
      }
//int w=v_matrixFengChang.at(0)->p_SpacerItem->geometry().width();
  //  p_matrixTop->p_lableSpace->setFixedWidth(w);







    }

    qDebug()<<v_matrixFengChang.count()<<"fengchangcout";
}



void MainWindow::clearWidgets(int index)
{

    qDebug()<<index;

    switch (index) {
    case 0:

      /*  ui->horizontalLayout_22->removeWidget( p_windFieldProgress[0]->p_num);
         ui->horizontalLayout_22->removeWidget( p_windFieldProgress[0]->p_progress);

         delete p_windFieldProgress[0]->p_num;
          delete p_windFieldProgress[0]->p_progress;*/
        for(int i=0;i<8;i++){

            p_topleftState[i]->p_HLayout->removeWidget(p_topleftState[i]->p_lable);
            p_topleftState[i]->p_HLayout->removeWidget(p_topleftState[i]->p_num);
            p_topleftState[i]->p_HLayout->removeWidget(p_topleftState[i]->p_state);
            p_VTopleftLayout->removeItem(p_topleftState[i]->p_HLayout);

           delete p_topleftState[i]->p_HLayout;
              delete p_topleftState[i]->p_lable;
              delete p_topleftState[i]->p_num;
              delete p_topleftState[i]->p_state;
           delete p_mapState[i]->p_name;
            delete p_mapState[i]->p_fengjiIcon;
            delete p_mapState[i];
             delete   p_topleftState[i];



        }


        for(int i=0;i<7;i++){
           p_icon[i]->deleteLater();

            p_state[i]->p_HLayout->removeWidget(p_state[i]->p_icon);
            p_state[i]->p_HLayout->removeWidget(p_state[i]->p_num);
            p_state[i]->p_HLayout->removeWidget(p_state[i]->p_state);
            p_state[i]->p_HLayout->removeWidget(p_state[i]->p_lable);
            p_state[i]->p_icon->deleteLater();
            p_state[i]->p_lable->deleteLater();
            p_state[i]->p_num->deleteLater();
            p_state[i]->p_state->deleteLater();
            p_state[i]->p_HLayout->deleteLater();
            p_state[i]->p_widget->deleteLater();

            delete  p_state[i]->p_icon;
              delete p_state[i]->p_lable;
              delete  p_state[i]->p_num;
              delete p_state[i]->p_state;
            delete p_state[i]->p_HLayout;
              delete p_state[i]->p_widget;
              delete p_icon[i];
              delete p_state[i];

        }

      for(int i=0;i<3;i++){
            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_winds[0]);
            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_winds[1]);
            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_winds[2]);

            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_powers[0]);
            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_powers[1]);
            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_powers[2]);

            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_electricitys[0]);
            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_electricitys[1]);
            p_mapNums->p_HLayouts[i]->removeWidget(p_mapNums->p_electricitys[2]);
            p_mapNums->p_VLayout->removeItem(p_mapNums->p_HLayouts[i]);
            p_mapNums->p_HLayouts[i]->deleteLater();
            delete p_mapNums->p_HLayouts[i];
      }

      for(int i=0;i<3;i++){

          p_mapNums->p_winds[i]->deleteLater();
            p_mapNums->p_electricitys[i]->deleteLater();
            p_mapNums->p_powers[i]->deleteLater();
          delete p_mapNums->p_winds[i];
          delete p_mapNums->p_electricitys[i];
          delete p_mapNums->p_powers[i];
      }

      p_mapNums->p_VLayout->deleteLater();
      p_mapNums->p_widget->deleteLater();
      delete p_mapNums->p_VLayout;
      delete p_mapNums->p_widget;
      /*  for(int i=0;i<8;i++){
            p_topleftState[i]->p_HLayout=NULL;
              p_topleftState[i]->p_lable=NULL;
              p_topleftState[i]->p_num=NULL;
               p_topleftState[i]->p_state=NULL;
           p_mapState[i]->p_name=NULL;
              p_mapState[i]->p_fengjiIcon=NULL;
        }

        for(int i=0;i<7;i++){

             p_state[i]->p_icon=NULL;
               p_state[i]->p_lable=NULL;
               p_state[i]->p_num=NULL;
               p_state[i]->p_state=NULL;
             p_state[i]->p_HLayout=NULL;
               p_state[i]->p_widget=NULL;
               p_icon[i]=NULL;
              p_state[i]=NULL;

        }*/
      p_topleftwidget->removeEventFilter(p_VTopleftLayout);
      delete  p_VTopleftLayout;
       delete  p_lable[0];
         delete p_topleftlable;
         delete  p_topleftwidget;
         delete  p_toprightHlable;
         delete p_toprightWindlable;
          delete  p_toprightVlable;
         delete  p_toprightPowerlable;
         delete  p_toprightwidget;

         /*p_VTopleftLayout=NULL;
            p_lable[0]=NULL;
          p_topleftlable=NULL;
           p_topleftwidget=NULL;
           p_toprightHlable=NULL;
          p_toprightWindlable=NULL;
            p_toprightVlable=NULL;
           p_toprightPowerlable=NULL;

           p_toprightwidget=NULL;*/

        break;

    case 1:

      /* QLayoutItem *item;

         while((item = ui->vLayoutStacke2_1->takeAt(0)) != 0){
             //删除widget
             if(item->widget()){
               // ui->vLayoutStacke2_1->removeWidget(item->widget());
                  QLayoutItem *item1;

                        QLayout *childLayout1=item->widget()->layout();

                   if(childLayout1){
                     while((item1 = childLayout1->takeAt(0)) != 0){

                         if(item1->widget()){
                             childLayout1->removeWidget(item1->widget());
                             //item1->widget()->deleteLater();
                           //  delete item1->widget();
                                item1->widget()->hide();
                         }
                         if(item1->spacerItem()){
                             childLayout1->removeItem(item1->spacerItem());
                             //item1->widget()->deleteLater();
                            // delete item1->spacerItem();
                             //item1->spacerItem();
                         }


                     }

                          delete childLayout1;
                     }
                    delete item1;

               // delete item->widget()->hide();
                 item->widget()->deleteLater();
             }
             //删除子布局

         /*  QLayout *childLayout = item->layout();
             if(childLayout){

                 QLayoutItem *item2;
                  while((item2 = childLayout->takeAt(0)) != 0){
                      //删除widget
                      if(item2->widget()){
                          childLayout->removeWidget(item2->widget());
                          delete item2->widget();

                          //item->widget()->deleteLater();
                      }
                      //删除子布局
                      QLayout *childLayout2 = item2->layout();
                      if(childLayout2){
                         // clearLayout(childLayout);
                          delete childLayout2;
                      }
                      delete item2;
                  }


                // clearLayout(childLayout);
                 delete childLayout;
             }

         }

         // delete item;*/


        break;

    case 2:

        break;

    case 3:

        break;

    case 4:

        break;

    case 5:

        break;

    case 6:

        break;


    case 7:

        break;


    default:
        break;
    }

 /* p_VTopleftLayout=NULL;
  p_topleftwidget=NULL;*/
}

void MainWindow::setMatrixNames()
{

    bool first=true;
    qDebug()<<"setMatrixDates"<<GYSCADAConfig::getInstance()->getUserName();
    QList<int> stationIds = GYSCADAConfig::getInstance()->getStationIds();

    for (QList<int>::iterator itStationId = stationIds.begin(); itStationId != stationIds.end(); ++itStationId) {
        // Station name and tree item
        // DomainObject for Station
        DomainObjectStation* domainObjectStation = new DomainObjectStation;
       domainObjectStation->setName(GYSCADAConfig::getInstance()->getStationName(*itStationId));
        QString FengChangName=GYSCADAConfig::getInstance()->getStationName(*itStationId);
        qDebug()<<GYSCADAConfig::getInstance()->getStationName(*itStationId);
        domainObjects.append(domainObjectStation);
       /* if(first){
            this->domainObject=domainObjectStation;
        }
        first=false;*/
        // Set Controls
        int fengChangid=0;
        if(FengChangName=="西八千风电场"){
            fengChangid=4;
            FengChangIdRevices.append(fengChangid);
        }
        if(FengChangName=="凌海风电场"){
            fengChangid=1;
             FengChangIdRevices.append(fengChangid);
        }
        domainObjectStation->setControlInfos(GYSCADAConfig::getInstance()->getStationControls(*itStationId));
        //  qDebug()<<*itStationId;

        // Add Line node to station node
        QList<int> lineIds = GYSCADAConfig::getInstance()->getStationLines(*itStationId);
        int fengchangFj=0;
    //    qDebug()<<stationIds.count()<<"  "<<lineIds.count();
        for (QList<int>::iterator itLineId = lineIds.begin(); itLineId != lineIds.end(); ++itLineId) {
            // Line name and tree item
            // DomainObject for Line
            DomainObjectLine* domainObjectLine = new DomainObjectLine(domainObjectStation);
            domainObjectLine->setName(GYSCADAConfig::getInstance()->getLineName(*itLineId));
            domainObjectStation->addChild(domainObjectLine);


            // Set Controls
            domainObjectLine->setControlInfos(GYSCADAConfig::getInstance()->getLineControls(*itLineId));
            QString str_addr,str_line,str_name,str_control,str_state,str_tran,str_pointId;

            str_line=GYSCADAConfig::getInstance()->getLineName(*itLineId);
            int point;
            ControlInfo contol_info;
            QMap<int,QString>M_addr;
            // Add Turbine node to Line node
            QList<int> turbineIds = GYSCADAConfig::getInstance()->getLineTurbines(*itLineId);

          //   qDebug()<<*itLineId;
            for (QList<int>::iterator itTurbineId = turbineIds.begin(); itTurbineId != turbineIds.end(); ++itTurbineId) {
                // Turbine name and tree item
            //   qDebug()<<"3";
                // DomainObject for Turbine
               // qDebug()<<*itTurbineId;

                DomainObjectTurbine* domainObjectTurbine = new DomainObjectTurbine(domainObjectLine);
                domainObjectLine->addChild(domainObjectTurbine);



                str_addr=GYSCADAConfig::getInstance()->getTurbinePoints(*itTurbineId).value(0);
              //  point=GYSCADAConfig::getInstance()->getTurbinePoints(*itTurbineId);
                str_name=GYSCADAConfig::getInstance()->getTurbineName(*itTurbineId);
              //  str_control=GYSCADAConfig::getInstance()->getTurbineControls(*itTurbineId);

                str_state=GYSCADAConfig::getInstance()->getTurbineDefaultState(*itTurbineId);
            //    str_tran=GYSCADAConfig::getInstance()->getTurbineTransition(*itTurbineId);
                str_pointId=GYSCADAConfig::getInstance()->getTurbineStatePoint(*itTurbineId);
                // Set Point Addr
                domainObjectTurbine->setPointsAddr(GYSCADAConfig::getInstance()->getTurbinePoints(*itTurbineId));
                // Set Name
                domainObjectTurbine->setName(GYSCADAConfig::getInstance()->getTurbineName(*itTurbineId));
                // Set Controls
                domainObjectTurbine->setControlInfos(GYSCADAConfig::getInstance()->getTurbineControls(*itTurbineId));
                // Set State Point id
                domainObjectTurbine->setStatePointId(GYSCADAConfig::getInstance()->getTurbineStatePoint(*itTurbineId));
                // set Default State
                domainObjectTurbine->setDefaultState(GYSCADAConfig::getInstance()->getTurbineDefaultState(*itTurbineId));
                // Set Transition
                domainObjectTurbine->setTransition(GYSCADAConfig::getInstance()->getTurbineTransition(*itTurbineId));

          //     qDebug()<<"addr:"<<str_addr<<"name:"<<str_name<<"control:"<<str_control<<"state:"<<str_state<<"tran:"<<str_tran<<
            //             "pointid:"<<str_pointId<<endl;
                // Add Turbine node to Line

                 emit setFengChangFJName(fengChangid,fengchangFj,str_name);
                emit setFengChangFJName(fengChangid+15,fengchangFj,str_name);
               v_matrixFengChang.at(fengChangid)->DomainObjectTurbines_One.append(domainObjectTurbine);
               v_matrixFengChang.at(fengChangid+15)->DomainObjectTurbines_One.append(domainObjectTurbine);
               //  qDebug()<<fengchangFj;
              // qDebug()<<str_line<<"  "<<str_name<<endl;
                fengchangFj++;
            }

            // Add Line node to station

        }

        // Add Station node to tree
      //  treeWidget->addTopLevelItem(itemStation);
    }

   /* for(int j=0;j<domainObjects.count();j++){

        QVector<DomainObject*> v_domainObjects = QVector<DomainObject*>::fromList(domainObjects.at(j)->getDescendant());
    }*/
}

void MainWindow::setMatrixNums()
{

    QList<int> TopFengChangIds;
    qlonglong TopWindCount=0,TopPowerCount=0;


    for(int j=0;j<domainObjects.count();j++){

        QVector<DomainObject*> v_domainObjects = QVector<DomainObject*>::fromList(domainObjects.at(j)->getDescendant());
          // qDebug()<<v_domainObjects.count();

   // v_domainObjects1=QVector<DomainObject*>::fromList(domainObjects.at(0)->getDescendant());
   // qDebug()<<v_domainObjects.count();
              double windCount=0,powerCount=0;
            QList<int> states;
            for(int i=0;i<7;i++){
                states.append(0);
            }
            states.replace(0,v_domainObjects.count());
              for(int i=0;i<v_domainObjects.count();i++){
                   DomainObjectTurbine* turbine = (DomainObjectTurbine*)v_domainObjects[i];

                    QVariant wind=turbine->getPointValue(1);
                     QVariant power=turbine->getPointValue(2);
                     windCount +=wind.toLongLong();
                     powerCount +=power.toLongLong();

                     TopWindCount +=wind.toLongLong();
                     TopPowerCount +=power.toLongLong();
                     QString state=turbine->getState();

                     if(state=="并网"){
                        states.replace(1,states.at(1)+1);

                         }
                     if(state=="待机"){
                           states.replace(2,states.at(2)+1);

                         }
                     if(state=="故障"){
                       states.replace(3,states.at(3)+1);

                         }
                     if(state=="维护"){
                           states.replace(4,states.at(4)+1);

                         }
                     if(state=="离线"){
                          states.replace(5,states.at(5)+1);

                         }
                     if(state=="限电"){
                          states.replace(6,states.at(6)+1);

                         }
                     int fengChangid=0;
                     switch (j) {
                     case 0:
                         fengChangid=4;

                         if(i==v_domainObjects.count()-1){
                             double p_wind=windCount/v_domainObjects.count();
                             emit setFengChangFJTops(fengChangid,QString::number(p_wind,'g',4),QString::number(powerCount,'g',4),states);
                               emit setFengChangFJTops(fengChangid+15,QString::number(windCount/v_domainObjects.count(),'g',4),QString::number(powerCount,'g',6),states);
                         }
                         emit setFengChangFJNums(fengChangid,i,QString::number(wind.toLongLong(),10),QString::number(power.toLongLong(),10),state);
                        emit setFengChangFJNums(fengChangid+15,i,QString::number(wind.toLongLong(),10),QString::number(power.toLongLong(),10),state);

                         TopFengChangIds.append(fengChangid);
                          TopFengChangIds.append(fengChangid+15);
                         break;//西八千风场
                     case 1:
                         fengChangid=1;

                         if(i==v_domainObjects.count()-1){
                             emit setFengChangFJTops(fengChangid,QString::number(windCount/v_domainObjects.count(),'g',4),QString::number(powerCount,'g',4),states);
                               emit setFengChangFJTops(fengChangid+15,QString::number(windCount/v_domainObjects.count(),'g',4),QString::number(powerCount,'g',4),states);
                         }
                           emit setFengChangFJNums(fengChangid,i,QString::number(wind.toLongLong(),10),QString::number(power.toLongLong(),10),state);
                         emit setFengChangFJNums(fengChangid+15,i,QString::number(wind.toLongLong(),10),QString::number(power.toLongLong(),10),state);
                          TopFengChangIds.append(fengChangid);
                           TopFengChangIds.append(fengChangid+15);
                        break;//凌海风场
                     default:
                         break;
                     }




              }







    }


    emit setMatrixTops(TopFengChangIds,QString::number(TopWindCount,10),QString::number(TopPowerCount,10));


}

bool MainWindow::eventFilter(QObject *target, QEvent *e)
{


    for(int i=0;i<8;i++){
        if(target==p_mapState[i]->p_name){
            if(e->type()==QEvent::Enter){
                p_mapNums->p_widget->move(p_mapState[i]->p_name->pos().x()-p_mapNums->p_widget->width(),
                                          p_mapState[i]->p_name->pos().y());

                p_mapNums->p_widget->show();
                break;
            }

            }
    }

    for(int i=0;i<3;i++){
        if(target==p_mapNums->p_winds[i]){
            if(e->type()==QEvent::Enter){
                p_mapNums->p_winds[0]->setStyleSheet("border-width: 0px;\
                                                      background-color: #1E5676;");
                        p_mapNums->p_winds[1]->setStyleSheet("border-width: 0px;\
                                                              background-color: #1E5676;");
                        p_mapNums->p_winds[2]->setStyleSheet("border-width: 0px;\
                                                              background-color: #1E5676;");
             p_mapNums->p_winds[1]->setStyleSheet("border-width: 0px;\
                                                             background-color:#1E5676;\
                                                              color: #29CBD2;");

                    break;

            }
            if(e->type()==QEvent::Leave){

                p_mapNums->p_winds[0]->setStyleSheet("border-width: 0px;\
                                                      background-color: #236696;");

                        p_mapNums->p_winds[2]->setStyleSheet("border-width: 0px;\
                                                              background-color: #236696;");
             p_mapNums->p_winds[1]->setStyleSheet("border-width: 0px;\
                                                             background-color:#236696;\
                                                              color: #29CBD2;");
            }


        }

        if(target==p_mapNums->p_electricitys[i]){
            if(e->type()==QEvent::Enter){
                p_mapNums->p_electricitys[0]->setStyleSheet("border-width: 0px;\
                                                      background-color: #1E5676;");

                        p_mapNums->p_electricitys[2]->setStyleSheet("border-width: 0px;\
                                                              background-color: #1E5676;");
             p_mapNums->p_electricitys[1]->setStyleSheet("border-width: 0px;\
                                                             background-color:#1E5676;\
                                                              color: #29CBD2;");
                break;

            }
            if(e->type()==QEvent::Leave){

                p_mapNums->p_electricitys[0]->setStyleSheet("border-width: 0px;\
                                                      background-color: #236696;");

                        p_mapNums->p_electricitys[2]->setStyleSheet("border-width: 0px;\
                                                              background-color: #236696;");
             p_mapNums->p_electricitys[1]->setStyleSheet("border-width: 0px;\
                                                             background-color:#236696;\
                                                              color: #29CBD2;");
            }


        }

        if(target==p_mapNums->p_powers[i]){
            if(e->type()==QEvent::Enter){
                p_mapNums->p_powers[0]->setStyleSheet("border-width: 0px;\
                                                      background-color: #1E5676;");

                        p_mapNums->p_powers[2]->setStyleSheet("border-width: 0px;\
                                                              background-color: #1E5676;");
             p_mapNums->p_powers[1]->setStyleSheet("border-width: 0px;\
                                                             background-color:#1E5676;\
                                                              color: #29CBD2;");

                break;

            }
            if(e->type()==QEvent::Leave){

                p_mapNums->p_powers[0]->setStyleSheet("border-width: 0px;\
                                                      background-color: #236696;");

                        p_mapNums->p_powers[2]->setStyleSheet("border-width: 0px;\
                                                              background-color: #236696;");
             p_mapNums->p_powers[1]->setStyleSheet("border-width: 0px;\
                                                             background-color:#236696;\
                                                              color: #29CBD2;");
            }

        }


    }


    if(target==p_topMapNumsHide){

        if(!p_topMapNumsHide->isHidden()){
            if(e->type()==QEvent::Enter){
               p_mapNums->p_widget->hide();

            }
        }


        }


    for(int i=0;i<v_matrixFengChang.count();i++){

          if(target==v_matrixFengChang.at(i)->p_fengChang){


              if(e->type()==QEvent::Enter){

                  v_matrixFengChang.at(i)->p_fengChang->setStyleSheet("color: #FBFDFB;\
                                                                    border-width: 0px;\
                                                                    border-color: #31b9fb;\
                                                                    border-bottom-color: #31b9fb;\
                                                                       background-color:#005CA2;\
                                                                    border-style: solid;\
                                                                    font-size:14px;\
                                                                    font-family:雅黑;");

              }
              if(e->type()==QEvent::Leave){
                  v_matrixFengChang.at(i)->p_fengChang->setStyleSheet("color: #FBFDFB;\
                                                                    border-width: 0px;\
                                                                    border-color: #31b9fb;\
                                                                    border-bottom-color: #31b9fb;\
                                                                       background-color: #1F5776;\
                                                                    border-style: solid;\
                                                                    font-size:14px;\
                                                                    font-family:雅黑;");
              }
              if(e->type()==QEvent::MouseButtonPress){
                 //p_mapNums->p_widget->hide();
                  F_matrixControlForm->show();
                  qDebug()<<"press";

              }


          }

    }



       if(v_matrixFengChang.count()<1){
       return false;
   }


         for(int j=0;j<v_matrixFengChang.count();j++){


            QLayoutItem *item;
         int w=v_matrixFengChang.at(j)->p_gridLayout->itemAt(0)->widget()->width();
             for(int i=0;i<v_matrixFengChang.at(j)->p_gridLayout->count();i++){
       item=v_matrixFengChang.at(j)->p_gridLayout->itemAt(i);

       if(item->widget()==target){
          if(!menuFlag){

            if(e->type()==QEvent::Enter){
                if(menuHideFirst){
                    menuHideFirst=false;
                }

              /*  if(i==v_matrixFengChang.at(j)->p_gridLayout->count()-1){

                    item->widget()->setStyleSheet("color: #F0F5F9;\
                                                  border-width: 1px;\
                                                  border-color: #0A5BA0;\
                                                  border-bottom-color: #0A5BA0;\
                                                  background-color: #F9F0F8;\
                                                  border-style: solid;\
                                                  font-size:12px;\
                                                  font-family:雅黑;");
                                                  break;

                }*/
                enter=true;
                item->widget()->setStyleSheet("color: #F0F5F9;\
                                              border-width: 1px;\
                                              border-color: #0A5BA0;\
                                              border-bottom-color: #0A5BA0;\
                                              background-image: url(:/new/images/images/矩阵顶部-经过.png);\
                                              border-style: solid;\
                                              font-size:12px;\
                                              font-family:雅黑;");


               emit sendMatrixFJEnter(j,i);


            }
            if(e->type()==QEvent::Leave){

                enter=false;
                item->widget()->setStyleSheet("color:#030708;\
                                                    border-width: 1px;\
                                                     border-color: #0A5BA0;\
                                                      border-bottom-color: #0A5BA0;\
                                                    background-image: url(:/new/images/images/矩阵-离线.png);\
                                                    border-style: solid;\
                                                     font-size:12px;\
                                                  font-family:雅黑;");




            }

       }


          else{


                  if(e->type()==QEvent::MouseButtonPress){
                      if(!p_matrixmenuForm->isHidden()){
                      p_matrixmenuForm->hide();
                      menuFlag=false;
                     menuHideFirst=true;
                     /* item->widget()->setStyleSheet("color: #B1A782;\
                                                    border-width: 1px;\
                                                    border-color: #0A5BA0;\
                                                    border-bottom-color: #0A5BA0;\
                                                    background-image: url(:/new/images/images/矩阵顶部-经过.png);\
                                                    border-style: solid;\
                                                    font-size:12px;\
                                                    font-family:雅黑;");

                      emit sendMatrixFJEnter(j,i);*/



                      item=v_matrixFengChang.at(matrixmenu_row)->p_gridLayout->itemAt(matrixmenu_index);
                     QString style=v_matrixFengChang.at(matrixmenu_row)->currentStyles.at(matrixmenu_index);

                             item->widget()->setStyleSheet(style);

                     /*    item->widget()->setStyleSheet("color:#030708;\
                                                             border-width: 1px;\
                                                              border-color: #0A5BA0;\
                                                               border-bottom-color: #0A5BA0;\
                                                             background-image: url(:/new/images/images/矩阵-离线.png);\
                                                             border-style: solid;\
                                                              font-size:12px;\
                                                           font-family:雅黑;");*/




                    /*if(matrixmenu_index>5&&matrixmenu_index<12||matrixmenu_index>30&&matrixmenu_index<35){
                         item->widget()->setStyleSheet("color:#030708;\
                                                             border-width: 1px;\
                                                              border-color: #0A5BA0;\
                                                               border-bottom-color: #0A5BA0;\
                                                             background-image: url(:/new/images/images/矩阵-待机.png);\
                                                             border-style: solid;\
                                                              font-size:12px;\
                                                           font-family:雅黑;");
                                                                }*/

                      }

              }
          }
       }
   }
}


         return false;
}

int MainWindow::getMatrixTopFengJiCount(int pageId)
{
     int tag=0;
    switch (pageId) {
    case 0:
         pageFengChangCounts.at(0);
        for(int i=0;i<v_matrixFengChang.count();i++){

        }
        break;

    case 1:
    // int j=pageFengChangCounts.at(0);
        tag=pageFengChangCounts.at(0);
        qDebug()<<tag<<"fengchang";
        for(int i=0;i<pageFengChangCounts.at(0);i++){

        }
        break;
    case 2:
    /*    int j=pageFengChangCounts.at(0)+pageFengChangCounts.at(1);
        for(int i=j;i<pageFengChangCounts.at(2);i++){

        }
        break;*/
    default:
        break;
    }
}

void MainWindow::setMatrixTopStates(int pageId,QList<int> FengChangs)
{
    int tag=0;
    double a[15]={0};
    int fengchangCount=0;
   switch (pageId) {
   case 0:

       for(int i=0;i<pageFengChangCounts.at(0);i++){

            if(FengChangs.contains(i)){

                fengchangCount++;
               a[0]+=v_matrixFengChang.at(i)->p_num[1]->text().toDouble();
               a[1]+=v_matrixFengChang.at(i)->p_num[2]->text().toDouble();
              qDebug()<<i<<"state";
               for(int j=0;j<7;j++){
                  // QString state=v_matrixFengChang.at(i)->FJstates.at(j);
                //   qDebug()<<state.toDouble()<<"state";
                   qDebug()<<v_matrixFengChang.at(i)->p_state[j]->text();
                   a[j+2]+=v_matrixFengChang.at(i)->p_state[j]->text().toDouble();
               }
            }
       }
       if(fengchangCount==0){
           break;
       }
       a[0]=a[0]/fengchangCount;

       for(int i=0;i<9;i++){
           topMatrixStates.append(a[i]);
       }

       break;

   case 1:

   // int j=pageFengChangCounts.at(0);
       tag=pageFengChangCounts.at(0);
       qDebug()<<tag<<"fengchang"<<pageFengChangCounts.at(1);
       for(int i=tag;i<pageFengChangCounts.at(1)+tag;i++){
          qDebug()<<i;
           if(FengChangs.contains(i)){
               fengchangCount++;
              a[0]+=v_matrixFengChang.at(i)->p_num[1]->text().toDouble();
              a[1]+=v_matrixFengChang.at(i)->p_num[2]->text().toDouble();
             qDebug()<<i<<"state";
              for(int j=0;j<7;j++){
                 // QString state=v_matrixFengChang.at(i)->FJstates.at(j);
               //   qDebug()<<state.toDouble()<<"state";
                  qDebug()<<v_matrixFengChang.at(i)->p_state[j]->text();
                  a[j+2]+=v_matrixFengChang.at(i)->p_state[j]->text().toDouble();
              }
           }
       }
       if(fengchangCount==0){
           break;
       }
       a[0]=a[0]/fengchangCount;

       for(int i=0;i<9;i++){
           topMatrixStates.append(a[i]);
       }

       break;
   case 2:

       tag=pageFengChangCounts.at(0)+pageFengChangCounts.at(1);
       qDebug()<<tag<<"fengchang"<<pageFengChangCounts.at(2);
       for(int i=tag;i<pageFengChangCounts.at(2)+tag;i++){
          qDebug()<<i;
           if(FengChangs.contains(i)){
               fengchangCount++;
              a[0]+=v_matrixFengChang.at(i)->p_num[1]->text().toDouble();
              a[1]+=v_matrixFengChang.at(i)->p_num[2]->text().toDouble();
             qDebug()<<i<<"state";
              for(int j=0;j<7;j++){
                 // QString state=v_matrixFengChang.at(i)->FJstates.at(j);
               //   qDebug()<<state.toDouble()<<"state";
                  qDebug()<<v_matrixFengChang.at(i)->p_state[j]->text();
                  a[j+2]+=v_matrixFengChang.at(i)->p_state[j]->text().toDouble();
              }
           }
       }
       if(fengchangCount==0){
           break;
       }
       a[0]=a[0]/fengchangCount;

       for(int i=0;i<9;i++){
           topMatrixStates.append(a[i]);
       }

       break;

   case 3:

       tag=pageFengChangCounts.at(0)+pageFengChangCounts.at(1)+pageFengChangCounts.at(2);
       qDebug()<<tag<<"fengchang"<<pageFengChangCounts.at(3);
       for(int i=tag;i<pageFengChangCounts.at(3)+tag;i++){
          qDebug()<<i;
           if(FengChangs.contains(i)){
               fengchangCount++;
              a[0]+=v_matrixFengChang.at(i)->p_num[1]->text().toDouble();
              a[1]+=v_matrixFengChang.at(i)->p_num[2]->text().toDouble();
             qDebug()<<i<<"state";
              for(int j=0;j<7;j++){
                 // QString state=v_matrixFengChang.at(i)->FJstates.at(j);
               //   qDebug()<<state.toDouble()<<"state";
                  qDebug()<<v_matrixFengChang.at(i)->p_state[j]->text();
                  a[j+2]+=v_matrixFengChang.at(i)->p_state[j]->text().toDouble();
              }
           }
       }
       if(fengchangCount==0){
           break;
       }
       a[0]=a[0]/fengchangCount;

       for(int i=0;i<9;i++){
           topMatrixStates.append(a[i]);
       }

       break;
   case 4:

       tag=pageFengChangCounts.at(0)+pageFengChangCounts.at(1)+pageFengChangCounts.at(2)+pageFengChangCounts.at(3);
       qDebug()<<tag<<"fengchang"<<pageFengChangCounts.at(4);
       for(int i=tag;i<pageFengChangCounts.at(4)+tag;i++){
          qDebug()<<i;
           if(FengChangs.contains(i)){
               fengchangCount++;
              a[0]+=v_matrixFengChang.at(i)->p_num[1]->text().toDouble();
              a[1]+=v_matrixFengChang.at(i)->p_num[2]->text().toDouble();
             qDebug()<<i<<"state";
              for(int j=0;j<7;j++){
                 // QString state=v_matrixFengChang.at(i)->FJstates.at(j);
               //   qDebug()<<state.toDouble()<<"state";
                  qDebug()<<v_matrixFengChang.at(i)->p_state[j]->text();
                  a[j+2]+=v_matrixFengChang.at(i)->p_state[j]->text().toDouble();
              }
           }
       }
       if(fengchangCount==0){
           break;
       }
       a[0]=a[0]/fengchangCount;

       for(int i=0;i<9;i++){
           topMatrixStates.append(a[i]);
       }

       break;
   default:
       break;
   }


}


void MainWindow::time_end()
{

    p_lable[0]->setStyleSheet("color:#31b9fb;\
                              border-width: 1.4px;\
                              border-color: #31b9fb;\
                              border-bottom-color: #31b9fb;\
                             background-color: #031830;\
                              border-style: solid;");
     p_lable[0]->setFixedSize(180,30);

     p_lable[0]->setText("日发电量（单位：万kwh）");
     p_lable[0]->move(ui->widget_20->pos().x()+ui->widget_20->width()-180,ui->widget_20->pos().y()+25);
   p_lable[0]->show();


    p_topleftState[0]->p_state->setText("装机容量");
     p_topleftState[1]->p_state->setText("日累计电量");
      p_topleftState[2]->p_state->setText("月累计电量");
       p_topleftState[3]->p_state->setText("年累计电量");
        p_topleftState[4]->p_state->setText("年利用小时");
         p_topleftState[5]->p_state->setText("月利用小时");
          p_topleftState[6]->p_state->setText("平均风速");
           p_topleftState[7]->p_state->setText("实时功率");

           p_state[0]->p_state->setText("接入");
           p_state[1]->p_state->setText("运行");
           p_state[2]->p_state->setText("待机");
           p_state[3]->p_state->setText("停机");
           p_state[4]->p_state->setText("维护");
           p_state[5]->p_state->setText("限电");
           p_state[6]->p_state->setText("离线");



   p_state[0]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[1]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[2]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[3]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[4]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[5]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[6]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_topleftwidget->setFixedWidth(ui->widget_4->width()-7);
  p_topleftlable->setFixedWidth(ui->widget_4->width()-30);
   p_toprightwidget->setFixedSize(ui->widget_21->width()-8,ui->widget_21->height());
    p_toprightVlable->setFixedWidth(ui->widget_21->width()-20);
     p_topleftwidget->setFixedHeight(ui->widget_4->height()-10);
      p_toprightHlable->setFixedHeight(ui->widget_21->height()-25);
     p_state[0]->p_widget->move(ui->widget_5->pos().x()+7,ui->widget_5->pos().y()+ui->widget->height()+10);
      p_state[1]->p_widget->move(ui->widget_7->pos().x()+7,ui->widget_7->pos().y()+ui->widget->height()+10);
        p_state[2]->p_widget->move(ui->widget_9->pos().x()+7,ui->widget_9->pos().y()+ui->widget->height()+10);
          p_state[3]->p_widget->move(ui->widget_11->pos().x()+7,ui->widget_11->pos().y()+ui->widget->height()+10);
            p_state[4]->p_widget->move(ui->widget_13->pos().x()+7,ui->widget_13->pos().y()+ui->widget->height()+10);
              p_state[5]->p_widget->move(ui->widget_15->pos().x()+7,ui->widget_15->pos().y()+ui->widget->height()+10);
                p_state[6]->p_widget->move(ui->widget_17->pos().x()+7,ui->widget_17->pos().y()+ui->widget->height()+10);

                for(int i=0;i<7;i++){
                    p_state[i]->p_widget->show();
                }

   p_topleftwidget->move(ui->widget_4->pos().x(),ui->widget_4->pos().y()+ui->widget_4->height()+ui->widget->height()-p_topleftwidget->height()-7);
   p_topleftlable->move(ui->widget_4->pos().x()+10,ui->widget_4->pos().y()+p_topleftState[5]->p_lable->pos().y()+
           p_topleftState[5]->p_lable->height()+ui->widget->height()+5);

   p_toprightwidget->move(ui->widget_21->pos().x()+8,ui->widget_21->pos().y()+ui->widget->height());
   p_toprightHlable->move(ui->widget_21->pos().x()+20,ui->widget_21->pos().y()+ui->widget->height()+15);
   p_toprightVlable->move(ui->widget_21->pos().x()+13,ui->widget_21->pos().y()+ui->widget->height()+p_toprightHlable->height()+5);
    p_toprightWindlable->move(ui->widget_21->pos().x()+160,ui->widget_21->pos().y()+ui->widget->height()+10);
     p_toprightPowerlable->move(ui->widget_21->pos().x()+160,ui->widget_21->pos().y()+ui->widget->height()+30);

     p_icon[0]->move(ui->widget_5->pos().x()+30,ui->widget_5->pos().y()+ui->widget->height()+18);
     p_icon[1]->move(ui->widget_7->pos().x()+30,ui->widget_7->pos().y()+ui->widget->height()+18);
     p_icon[2]->move(ui->widget_9->pos().x()+30,ui->widget_9->pos().y()+ui->widget->height()+18);
     p_icon[3]->move(ui->widget_11->pos().x()+30,ui->widget_11->pos().y()+ui->widget->height()+18);
     p_icon[4]->move(ui->widget_13->pos().x()+30,ui->widget_13->pos().y()+ui->widget->height()+18);
     p_icon[5]->move(ui->widget_15->pos().x()+30,ui->widget_15->pos().y()+ui->widget->height()+18);
     p_icon[6]->move(ui->widget_17->pos().x()+30,ui->widget_17->pos().y()+ui->widget->height()+18);
     p_icon[0]->show();
     p_icon[1]->show();
      p_icon[2]->show();
       p_icon[3]->show();
         p_icon[4]->show();
          p_icon[5]->show();
           p_icon[6]->show();
      double x,y,z,k;
//int a=ui->horizontalSpacer_23->width;
        p_mapState[0]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.50274,ui->widget_19->height()*0.682488+ui->widget->height());
        p_mapState[0]->p_fengjiIcon->show();
        p_mapState[0]->p_name->setText("兴城");
         p_mapState[0]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.472603,ui->widget_19->height()*0.731588+ui->widget->height());
        p_mapState[0]->p_name->show();
      /*  x=ui->widget_19->width()/2-20;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3+40;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[1]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.554795,ui->widget_19->height()*0.641571+ui->widget->height());
        p_mapState[1]->p_fengjiIcon->show();

        p_mapState[1]->p_name->setText("凌海");
         p_mapState[1]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.527397,ui->widget_19->height()*0.690671 +ui->widget->height());
        p_mapState[1]->p_name->show();
       /* x=ui->widget_19->width()/2+20;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3+15;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[2]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.513699,ui->widget_19->height()*0.584288+ui->widget->height());
        p_mapState[2]->p_fengjiIcon->show();
        p_mapState[2]->p_name->setText("北镇");
         p_mapState[2]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.465753,ui->widget_19->height()*0.633388+ui->widget->height());
        p_mapState[2]->p_name->show();

      /*  x=ui->widget_19->width()/2-25;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3-20;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[3]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.557534,ui->widget_19->height()*0.553191+ui->widget->height());
       p_mapState[3]->p_fengjiIcon->show();
       p_mapState[3]->p_name->setText("芳山");
        p_mapState[3]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.516438,ui->widget_19->height()*0.512275+ui->widget->height());
       p_mapState[3]->p_name->show();

       /* x=ui->widget_19->width()/2+12;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3-94;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[4]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.605479,ui->widget_19->height()*0.662848+ui->widget->height());
       p_mapState[4]->p_fengjiIcon->show();
       p_mapState[4]->p_name->setText("西八千");
        p_mapState[4]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.613699,ui->widget_19->height()* 0.718494+ui->widget->height());
       p_mapState[4]->p_name->show();

        /*x=ui->widget_19->width()/2+83;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3+32;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[5]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.609589,ui->widget_19->height()*0.504092+ui->widget->height());
        p_mapState[5]->p_fengjiIcon->show();
        p_mapState[5]->p_name->setText("调兵山");
         p_mapState[5]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.623288,ui->widget_19->height()*0.477905 +ui->widget->height());
        p_mapState[5]->p_name->show();
       /* x=ui->widget_19->width()/2+90;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3-115;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/

        p_mapState[6]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.657534,ui->widget_19->height()*0.545008+ui->widget->height());
        p_mapState[6]->p_fengjiIcon->show();
        p_mapState[6]->p_name->setText("台子山");
         p_mapState[6]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.671233,ui->widget_19->height()*0.592471+ui->widget->height());
        p_mapState[6]->p_name->show();
     /*   x=ui->widget_19->width()/2+125;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3-45;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
  //  qDebug()<<ui->widget_20->pos().x()<<ui->widget_21->pos().y();

    /*    p_windFieldProgress[0]->p_progress->move(ui->widget_20->pos().x()+ui->label_57->width()+20,
                                                 ui->widget_20->pos().y()+ui->widget->height()+ui->label_57->pos().y());
        p_windFieldProgress[0]->p_num->move(ui->label_57->pos().x()+ui->label_57->width()+p_windFieldProgress[0]->p_progress->width()+10,ui->label_57->pos().y()+ui->widget->height());
        p_windFieldProgress[0]->p_progress->show();
        p_windFieldProgress[0]->p_num->show();*/
       p_navigationlable->hide();
        //p_navigationlable->move(ui->boosterButton->pos().x()-10,5);
       //p_mapNums->p_widget->hide();
        if(!p_mapNums->p_widget->isHidden()){
            p_mapNums->p_widget->hide();
        }
        timeNum++;
        if(timeNum>=2){


            disconnect(timer,SIGNAL(timeout()),this,SLOT(time_end()));
             timer->stop();
             timeNum=0;
             timeStart_falg=true;

             connect(timer2,SIGNAL(timeout()),this,SLOT(time_update()));
              timer2->start(800);
        }

        p_toprightwidget->show();
        p_topleftwidget->show();
        p_toprightHlable->show();
        p_toprightPowerlable->show();
        p_toprightVlable->show();
        p_toprightwidget->show();
        p_toprightWindlable->show();
        p_topleftlable->show();

}

void MainWindow::time_update()
{

    this->setMatrixNums();
  //  int j=0;
   /* for(int i=0;i<v_domainObjects1.count();i++){
        DomainObjectTurbine* turbine = (DomainObjectTurbine*)v_domainObjects1[i];

         QVariant wind=turbine->getPointValue(1);
          QVariant power=turbine->getPointValue(2);
          int fengChangid=0;
          switch (j) {
          case 0:
              fengChangid=4;
              emit setFengChangFJNums(fengChangid,i,QString::number(wind.toLongLong(),10),QString::number(power.toLongLong(),10));
              emit setFengChangFJNums(fengChangid+15,i,QString::number(wind.toLongLong(),10),QString::number(power.toLongLong(),10));
              break;//西八千风场
          case 1:
              fengChangid=1;
              emit setFengChangFJNums(fengChangid,i,QString::number(wind.toLongLong(),10),QString::number(power.toLongLong(),10));
              emit setFengChangFJNums(fengChangid+15,i,QString::number(wind.toLongLong(),10),QString::number(power.toLongLong(),10));
              break;//凌海风场
          default:
              break;
          }




}*/

}

void MainWindow::showWindowMax()
{
    p_lable[0]->setStyleSheet("color:#31b9fb;\
                              border-width: 1.4px;\
                              border-color: #31b9fb;\
                              border-bottom-color: #31b9fb;\
                             background-color: #031830;\
                              border-style: solid;");
     p_lable[0]->setFixedSize(180,30);

     p_lable[0]->setText("日发电量（单位：万kwh）");
     p_lable[0]->move(ui->widget_20->pos().x()+ui->widget_20->width()-180,ui->widget_20->pos().y()+25);
   p_lable[0]->show();


    p_topleftState[0]->p_state->setText("装机容量");
     p_topleftState[1]->p_state->setText("日累计电量");
      p_topleftState[2]->p_state->setText("月累计电量");
       p_topleftState[3]->p_state->setText("年累计电量");
        p_topleftState[4]->p_state->setText("年利用小时");
         p_topleftState[5]->p_state->setText("月利用小时");
          p_topleftState[6]->p_state->setText("平均风速");
           p_topleftState[7]->p_state->setText("实时功率");

           p_state[0]->p_state->setText("接入");
           p_state[1]->p_state->setText("运行");
           p_state[2]->p_state->setText("待机");
           p_state[3]->p_state->setText("停机");
           p_state[4]->p_state->setText("维护");
           p_state[5]->p_state->setText("限电");
           p_state[6]->p_state->setText("离线");



   p_state[0]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[1]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[2]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[3]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[4]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[5]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_state[6]->p_widget->setFixedWidth(ui->widget_4->width()-7);
   p_topleftwidget->setFixedWidth(ui->widget_4->width()-7);
  p_topleftlable->setFixedWidth(ui->widget_4->width()-30);
   p_toprightwidget->setFixedSize(ui->widget_21->width()-8,ui->widget_21->height());
    p_toprightVlable->setFixedWidth(ui->widget_21->width()-20);
     p_topleftwidget->setFixedHeight(ui->widget_4->height()-10);
      p_toprightHlable->setFixedHeight(ui->widget_21->height()-25);
     p_state[0]->p_widget->move(ui->widget_5->pos().x()+7,ui->widget_5->pos().y()+ui->widget->height()+10);
      p_state[1]->p_widget->move(ui->widget_7->pos().x()+7,ui->widget_7->pos().y()+ui->widget->height()+10);
        p_state[2]->p_widget->move(ui->widget_9->pos().x()+7,ui->widget_9->pos().y()+ui->widget->height()+10);
          p_state[3]->p_widget->move(ui->widget_11->pos().x()+7,ui->widget_11->pos().y()+ui->widget->height()+10);
            p_state[4]->p_widget->move(ui->widget_13->pos().x()+7,ui->widget_13->pos().y()+ui->widget->height()+10);
              p_state[5]->p_widget->move(ui->widget_15->pos().x()+7,ui->widget_15->pos().y()+ui->widget->height()+10);
                p_state[6]->p_widget->move(ui->widget_17->pos().x()+7,ui->widget_17->pos().y()+ui->widget->height()+10);

                for(int i=0;i<7;i++){
                    p_state[i]->p_widget->show();
                }

   p_topleftwidget->move(ui->widget_4->pos().x(),ui->widget_4->pos().y()+ui->widget_4->height()+ui->widget->height()-p_topleftwidget->height()-7);
   p_topleftlable->move(ui->widget_4->pos().x()+10,ui->widget_4->pos().y()+p_topleftState[5]->p_lable->pos().y()+
           p_topleftState[5]->p_lable->height()+ui->widget->height()+5);

   p_toprightwidget->move(ui->widget_21->pos().x()+8,ui->widget_21->pos().y()+ui->widget->height());
   p_toprightHlable->move(ui->widget_21->pos().x()+20,ui->widget_21->pos().y()+ui->widget->height()+15);
   p_toprightVlable->move(ui->widget_21->pos().x()+13,ui->widget_21->pos().y()+ui->widget->height()+p_toprightHlable->height()+5);
    p_toprightWindlable->move(ui->widget_21->pos().x()+160,ui->widget_21->pos().y()+ui->widget->height()+10);
     p_toprightPowerlable->move(ui->widget_21->pos().x()+160,ui->widget_21->pos().y()+ui->widget->height()+30);

     p_icon[0]->move(ui->widget_5->pos().x()+30,ui->widget_5->pos().y()+ui->widget->height()+18);
     p_icon[1]->move(ui->widget_7->pos().x()+30,ui->widget_7->pos().y()+ui->widget->height()+18);
     p_icon[2]->move(ui->widget_9->pos().x()+30,ui->widget_9->pos().y()+ui->widget->height()+18);
     p_icon[3]->move(ui->widget_11->pos().x()+30,ui->widget_11->pos().y()+ui->widget->height()+18);
     p_icon[4]->move(ui->widget_13->pos().x()+30,ui->widget_13->pos().y()+ui->widget->height()+18);
     p_icon[5]->move(ui->widget_15->pos().x()+30,ui->widget_15->pos().y()+ui->widget->height()+18);
     p_icon[6]->move(ui->widget_17->pos().x()+30,ui->widget_17->pos().y()+ui->widget->height()+18);
     p_icon[0]->show();
      p_icon[1]->show();
       p_icon[2]->show();
        p_icon[3]->show();
         p_icon[4]->show();
          p_icon[5]->show();
           p_icon[6]->show();
      double x,y,z,k;
//int a=ui->horizontalSpacer_23->width;
        p_mapState[0]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.50274,ui->widget_19->height()*0.682488+ui->widget->height());
        p_mapState[0]->p_fengjiIcon->show();
        p_mapState[0]->p_name->setText("兴城");
         p_mapState[0]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.472603,ui->widget_19->height()*0.731588+ui->widget->height());
        p_mapState[0]->p_name->show();
      /*  x=ui->widget_19->width()/2-20;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3+40;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[1]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.554795,ui->widget_19->height()*0.641571+ui->widget->height());
        p_mapState[1]->p_fengjiIcon->show();

        p_mapState[1]->p_name->setText("凌海");
         p_mapState[1]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.527397,ui->widget_19->height()*0.690671 +ui->widget->height());
        p_mapState[1]->p_name->show();
       /* x=ui->widget_19->width()/2+20;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3+15;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[2]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.513699,ui->widget_19->height()*0.584288+ui->widget->height());
        p_mapState[2]->p_fengjiIcon->show();
        p_mapState[2]->p_name->setText("北镇");
         p_mapState[2]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.465753,ui->widget_19->height()*0.633388+ui->widget->height());
        p_mapState[2]->p_name->show();

      /*  x=ui->widget_19->width()/2-25;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3-20;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[3]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.557534,ui->widget_19->height()*0.553191+ui->widget->height());
       p_mapState[3]->p_fengjiIcon->show();
       p_mapState[3]->p_name->setText("芳山");
        p_mapState[3]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.516438,ui->widget_19->height()*0.512275+ui->widget->height());
       p_mapState[3]->p_name->show();

       /* x=ui->widget_19->width()/2+12;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3-94;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[4]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.605479,ui->widget_19->height()*0.662848+ui->widget->height());
       p_mapState[4]->p_fengjiIcon->show();
       p_mapState[4]->p_name->setText("西八千");
        p_mapState[4]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.613699,ui->widget_19->height()* 0.718494+ui->widget->height());
       p_mapState[4]->p_name->show();

        /*x=ui->widget_19->width()/2+83;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3+32;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
        p_mapState[5]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.609589,ui->widget_19->height()*0.504092+ui->widget->height());
        p_mapState[5]->p_fengjiIcon->show();
        p_mapState[5]->p_name->setText("调兵山");
         p_mapState[5]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.623288,ui->widget_19->height()*0.477905 +ui->widget->height());
        p_mapState[5]->p_name->show();
       /* x=ui->widget_19->width()/2+90;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3-115;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/

        p_mapState[6]->p_fengjiIcon->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.657534,ui->widget_19->height()*0.545008+ui->widget->height());
        p_mapState[6]->p_fengjiIcon->show();
        p_mapState[6]->p_name->setText("台子山");
         p_mapState[6]->p_name->move(ui->widget_19->pos().x()+ui->widget_19->width()*0.671233,ui->widget_19->height()*0.592471+ui->widget->height());
        p_mapState[6]->p_name->show();
     /*   x=ui->widget_19->width()/2+125;
        z=ui->widget_19->width();
        y=2*ui->widget_19->height()/3-45;
        k=ui->widget_19->height();
        qDebug()<<x/z<<"    "<<y/k<<endl;*/
  //  qDebug()<<ui->widget_20->pos().x()<<ui->widget_21->pos().y();

    /*    p_windFieldProgress[0]->p_progress->move(ui->widget_20->pos().x()+ui->label_57->width()+20,
                                                 ui->widget_20->pos().y()+ui->widget->height()+ui->label_57->pos().y());
        p_windFieldProgress[0]->p_num->move(ui->label_57->pos().x()+ui->label_57->width()+p_windFieldProgress[0]->p_progress->width()+10,ui->label_57->pos().y()+ui->widget->height());
        p_windFieldProgress[0]->p_progress->show();
        p_windFieldProgress[0]->p_num->show();*/
       p_navigationlable->hide();
        //p_navigationlable->move(ui->boosterButton->pos().x()-10,5);
       //p_mapNums->p_widget->hide();
        if(!p_mapNums->p_widget->isHidden()){
            p_mapNums->p_widget->hide();
        }


        p_toprightwidget->show();
        p_topleftwidget->show();
        p_toprightHlable->show();
        p_toprightPowerlable->show();
        p_toprightVlable->show();
        p_toprightwidget->show();
        p_toprightWindlable->show();
        p_topleftlable->show();
}

void MainWindow::on_hostButton_clicked()
{
  if(ui->stackedWidget->currentIndex()!=0){
       this->clearWidgets(ui->stackedWidget->currentIndex());
      this->setStates_Host();
      connect(timer,SIGNAL(timeout()),this,SLOT(time_end()));
       timer->start(100);


        if(p_topMapNumsHide->isHidden()){
               p_topMapNumsHide->show();
        }
  ui->stackedWidget->setCurrentIndex(0);
  }





}

void MainWindow::on_matrixButton_clicked()
{
    if(ui->stackedWidget->currentIndex()!=1){
      //  ui->label_4->setText("全部");
     //   ui->page_9->hide();
     //   ui->page_10->hide();
          this->clearWidgets(ui->stackedWidget->currentIndex());
      //  this->setStates_Matrix(0);
      /*  if(!p_mapNums->p_widget->isHidden()){
               p_mapNums->p_widget->hide();
        }
*/       //    ui->label_4->setText("全部");
        ui->scrollArea->verticalScrollBar()->setSliderPosition(0);

        if( !p_topMapNumsHide->isHidden()){
               p_topMapNumsHide->hide();
        }

       ui->stackedWidget_2->setCurrentIndex(0);
          ui->stackedWidget->setCurrentIndex(1);
        //   this->clearWidgets(ui->stackedWidget->currentIndex());
    }


}

void MainWindow::on_parameterButton_clicked()
{
    if(ui->stackedWidget->currentIndex()!=2){
          this->clearWidgets(ui->stackedWidget->currentIndex());
          ui->stackedWidget->setCurrentIndex(2);
    }
}

void MainWindow::on_controlButton_clicked()
{
    if(ui->stackedWidget->currentIndex()!=3){
          this->clearWidgets(ui->stackedWidget->currentIndex());
          ui->stackedWidget->setCurrentIndex(3);
    }
}

void MainWindow::on_mainParameterButton_clicked()
{
    if(ui->stackedWidget->currentIndex()!=4){
        this->clearWidgets(ui->stackedWidget->currentIndex());
        ui->stackedWidget->setCurrentIndex(4);
  }

}

void MainWindow::on_searchButton_clicked()
{
    if(ui->stackedWidget->currentIndex()!=5){
          this->clearWidgets(ui->stackedWidget->currentIndex());
          ui->stackedWidget->setCurrentIndex(5);
    }
}

void MainWindow::on_manageButton_clicked()
{
    if(ui->stackedWidget->currentIndex()!=6){
          this->clearWidgets(ui->stackedWidget->currentIndex());
          ui->stackedWidget->setCurrentIndex(6);
    }

}

void MainWindow::on_boosterButton_clicked()
{
    if(ui->stackedWidget->currentIndex()!=7){
          this->clearWidgets(ui->stackedWidget->currentIndex());
          ui->stackedWidget->setCurrentIndex(7);
    }
}

void MainWindow::on_all_Button_clicked()
{
    //ui->label_4->setText("全部");
    ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
   ui->stackedWidget_2->setCurrentIndex(0);


}

void MainWindow::on_liaoNing_Button_clicked()
{
   // ui->label_4->setText("辽宁省");
    ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
  ui->stackedWidget_2->setCurrentIndex(1);



}

void MainWindow::on_jiLin_Button_clicked()
{
  //  ui->label_4->setText("吉林省");
    ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
 ui->stackedWidget_2->setCurrentIndex(3);


}

void MainWindow::on_heiLongJiang_Button_clicked()
{
  //  ui->label_4->setText("黑龙江");
    ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
ui->stackedWidget_2->setCurrentIndex(2);


}

void MainWindow::on_mengDong_Button_clicked()
{

  //  ui->stackedWidget_2->setMaximumHeight(p_matrixId.at(4)->p_fengjiCount.count()*240);
 //   ui->label_4->setText("蒙东省");
      ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
ui->stackedWidget_2->setCurrentIndex(4);



}

void MainWindow::on_all_Button_2_clicked()
{
  //  ui->label_4->setText("全部");
     ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
    this->clearWidgets(ui->stackedWidget->currentIndex());

 ui->stackedWidget_2->setCurrentIndex(0);
    ui->stackedWidget->setCurrentIndex(1);

}

void MainWindow::on_liaoNing_Button_2_clicked()
{
  //  ui->label_4->setText("辽宁省");
     ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
    this->clearWidgets(ui->stackedWidget->currentIndex());

 ui->stackedWidget_2->setCurrentIndex(1);
    ui->stackedWidget->setCurrentIndex(1);
}

void MainWindow::on_jiLin_Button_2_clicked()
{
  //  ui->label_4->setText("吉林省");
     ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
    this->clearWidgets(ui->stackedWidget->currentIndex());


 ui->stackedWidget_2->setCurrentIndex(3);
    ui->stackedWidget->setCurrentIndex(1);
}

void MainWindow::on_heiLongJiang_Button_2_clicked()
{
 //   ui->label_4->setText("黑龙江");
     ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
    this->clearWidgets(ui->stackedWidget->currentIndex());

 ui->stackedWidget_2->setCurrentIndex(2);
    ui->stackedWidget->setCurrentIndex(1);
}

void MainWindow::on_mengDong_Button_2_clicked()
{
    //ui->label_4->setText("蒙东省");
     ui->scrollArea->verticalScrollBar()->setSliderPosition(0);
    this->clearWidgets(ui->stackedWidget->currentIndex());

 ui->stackedWidget_2->setCurrentIndex(4);
    ui->stackedWidget->setCurrentIndex(1);
}

void MainWindow::on_stackedWidget_2_customContextMenuRequested(const QPoint &pos)
{
qDebug()<<"customContextMenuRequested";
     matriFJrightClicked_falg=true;


     this->show_menu(matrixmenu_row,-1);
   //  QPoint  pt=cursor().pos();
             // p_matrixmenuForm->move(pt.rx(),pt.ry());
         //   p_matrixmenuForm->show();
   /* QMenu* p_menu=new QMenu(p_matrixmenuForm);
         QAction* a1=new QAction("启动",ui->widget_2);
          QAction* a2=new QAction("停机",ui->widget_2);
          QAction* a3=new QAction("复位",ui->widget_2);
          QAction* a4=new QAction("维护",ui->widget_2);
          QAction* a5=new QAction("取消维护",ui->widget_2);
          p_menu->addSection("风场信息");
          p_menu->addAction(a1);
          p_menu->addAction(a2);
          p_menu->addAction(a3);
          p_menu->addAction(a4);
          p_menu->addAction(a5);
    QPoint  pt=cursor().pos();
     p_menu->move(pt.rx(),pt.ry());
       p_menu->show();*/
    /* QPoint  pt=cursor().pos();
    p_matrixmenuForm->move(pt.rx(),pt.ry());
    p_matrixmenuForm->show();
      p_matrixmenuForm->show();*/



  // p_menubar->addMenu(p_menu);

   /*  QPoint  pt=cursor().pos();
     p_menu->move(pt.rx(),pt.ry());
      p_menu->show();*/





}

void MainWindow::on_exit_Button_clicked()
{
   QApplication *app;
   app->exit(0);
}

void MainWindow::show_menu(int row, int index)
{




    if(menuHideFirst){
        return;
    }
           if(matriFJrightClicked_falg&&index==-1&&enter){

               QLayoutItem *item;
                QPoint  pt=cursor().pos();
            /*   item=v_matrixFengChang.at(matrixmenu_row)->p_gridLayout->itemAt(matrixmenu_index);

               int y1=item->widget()->geometry().topLeft().ry()+p_matrixTop->p_widget->height()+ui->widget->height();

               qDebug()<<v_matrixFengChang.at(0)->p_widget->pos().y()<<"  "<<v_matrixFengChang.at(1)->p_widget->pos().y()<<"  "<<item->widget()->geometry().topLeft().ry()<<"  "<<y1<<"  "<<pt.ry();
               //qDebug()<<item->widget()->geometry().topLeft().rx()<<"  "<<item->widget()->geometry().topLeft().ry();
              if(pt.rx()>=item->widget()->geometry().topLeft().rx()&&pt.rx()<=(item->widget()->geometry().topLeft().rx()+item->widget()->width())
                       &&pt.ry()>=y1&&pt.ry()<=(y1+item->widget()->height()))
               {

                   qDebug()<<pt.ry()+p_matrixmenuForm->height();

                if(matrixmenu_index%13>=10&&(pt.ry()+p_matrixmenuForm->height())>=ui->centralWidget->height()){
                     p_matrixmenuForm->move(pt.rx()-p_matrixmenuForm->width(),pt.ry()-p_matrixmenuForm->height());

                     qDebug()<<"1";
                }

                else if((pt.ry()+p_matrixmenuForm->height())>=ui->centralWidget->height()){
                      p_matrixmenuForm->move(pt.rx(),pt.ry()-p_matrixmenuForm->height());

                      qDebug()<<"2";
                 }
                else if(matrixmenu_index%13>=10){

                          p_matrixmenuForm->move(pt.rx()-p_matrixmenuForm->width(),pt.ry()-15);

                          qDebug()<<"3";



                }
                else{
                    p_matrixmenuForm->move(pt.rx(),pt.ry()-15);

                    qDebug()<<"4";

                }

                p_matrixmenuForm->show();


               menuFlag=true;
               matriFJrightClicked_falg=false;
                 qDebug()<<matrixmenu_row<<"  "<<matrixmenu_index;



               }*/

                if(pt.rx()>=(deskWidth-p_matrixmenuForm->width())){
                    pt.rx()=pt.rx()-p_matrixmenuForm->width();
                }

                if(pt.ry()>=deskHeight-p_matrixmenuForm->height()){
                    pt.ry()=pt.ry()-p_matrixmenuForm->height();
                }
                p_matrixmenuForm->move(pt.rx(),pt.ry()-15);

                      qDebug()<<row<<index<<v_matrixFengChang.at(matrixmenu_row)->p_fengChang->text();
             if(FengChangIdRevices.contains(matrixmenu_row)){
                 p_matrixmenuForm->setFCname(v_matrixFengChang.at(matrixmenu_row)->p_fengChang->text());
                 p_matrixmenuForm->setFJname(v_matrixFengChang.at(matrixmenu_row)->FJnames.at(matrixmenu_index));
                 p_matrixmenuForm->setFJwind(v_matrixFengChang.at(matrixmenu_row)->FJwinds.at(matrixmenu_index));
                 p_matrixmenuForm->setFJpower(v_matrixFengChang.at(matrixmenu_row)->FJpowers.at(matrixmenu_index));
             }


               p_matrixmenuForm->show();


              menuFlag=true;
              matriFJrightClicked_falg=false;
               return;




              }
          if(menuFlag){
          return;
          }

          matrixmenu_row=row;
          matrixmenu_index=index;
           qDebug()<<matrixmenu_row<<"  "<<matrixmenu_index;

}



void MainWindow::setFengChangFjName_Slots(int Fengchang, int index, QString name)
{
    QString s_name=QObject::tr("<font size=5 ><b>%1</b></font>").arg(name);
    v_matrixFengChang.at(Fengchang)->FJnames.append(s_name);
    v_matrixFengChang.at(Fengchang)->FJpowers.append(s_name);
    v_matrixFengChang.at(Fengchang)->FJwinds.append(s_name);
      v_matrixFengChang.at(Fengchang)->FJstates.append(s_name);
}

void MainWindow::setFengChangFjNums_Slots(int Fengchang, int index, QString wind, QString power,QString state)
{
QString s_name= v_matrixFengChang.at(Fengchang)->FJnames.at(index);


 //   qDebug()<<wind<<power<<"nums";
 //   QString s_name=v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->text();
    //s_name=QObject::tr("<font size=5 ><b>%1</b></font>").arg(s_name);
    wind=wind+"m/s";
    power=power+"kw";

    v_matrixFengChang.at(Fengchang)->FJpowers.replace(index,power);
    v_matrixFengChang.at(Fengchang)->FJwinds.replace(index,wind);
    v_matrixFengChang.at(Fengchang)->FJstates.replace(index,state);
  //  qDebug()<<state;
   /* if(state=="装机"){
        v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->setStyleSheet(FJStateList.at(0));

        }*/


    if(state=="并网"){
        v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->setStyleSheet(FJStateList.at(1));
        v_matrixFengChang.at(Fengchang)->currentStyles.replace(index,FJStateList.at(1));

        }
    if(state=="待机"){
        v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->setStyleSheet(FJStateList.at(2));
        v_matrixFengChang.at(Fengchang)->currentStyles.replace(index,FJStateList.at(2));

        }
    if(state=="故障"){
        v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->setStyleSheet(FJStateList.at(3));
        v_matrixFengChang.at(Fengchang)->currentStyles.replace(index,FJStateList.at(3));

        }
    if(state=="维护"){
        v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->setStyleSheet(FJStateList.at(4));
        v_matrixFengChang.at(Fengchang)->currentStyles.replace(index,FJStateList.at(4));

        }
    if(state=="离线"){
        v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->setStyleSheet(FJStateList.at(5));
        v_matrixFengChang.at(Fengchang)->currentStyles.replace(index,FJStateList.at(5));

        }
    if(state=="限电"){
        v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->setStyleSheet(FJStateList.at(6));
        v_matrixFengChang.at(Fengchang)->currentStyles.replace(index,FJStateList.at(6));

        }

    if(enter&&!menuHideFirst){

         v_matrixFengChang.at(matrixmenu_row)->v_fengji.at(matrixmenu_index)->setStyleSheet(FJStateList.at(7));
    }
    else{

    }
    if(menuFlag&&FengChangIdRevices.contains(matrixmenu_row)){


       v_matrixFengChang.at(matrixmenu_row)->v_fengji.at(matrixmenu_index)->setStyleSheet(FJStateList.at(7));
        p_matrixmenuForm->setFCname(v_matrixFengChang.at(matrixmenu_row)->p_fengChang->text());
        p_matrixmenuForm->setFJname(v_matrixFengChang.at(matrixmenu_row)->FJnames.at(matrixmenu_index));
        p_matrixmenuForm->setFJwind(v_matrixFengChang.at(matrixmenu_row)->FJwinds.at(matrixmenu_index));
        p_matrixmenuForm->setFJpower(v_matrixFengChang.at(matrixmenu_row)->FJpowers.at(matrixmenu_index));

    }
    QString s_str=QObject::tr("<font size=5 ><b>%1</b></font>").arg(s_name)+
             QObject::tr("<br />")+
            QObject::tr("<font font   size=3>%1</font>").arg(wind)+
            QObject::tr("<br />")+
             QObject::tr("<font font  size=3>%1</font>").arg(power);

    v_matrixFengChang.at(Fengchang)->v_fengji.at(index)->setText(s_str);
}

void MainWindow::setFengChangFjTops_Slots(int Fengchang, QString windAve, QString powerCount,QList<int> states)
{
    v_matrixFengChang.at(Fengchang)->p_num[1]->setText(windAve);
    v_matrixFengChang.at(Fengchang)->p_num[2]->setText(powerCount);
    for(int i=0;i<states.count();i++){
         v_matrixFengChang.at(Fengchang)->p_state[i]->setText(QString::number(states.at(i),10));
    }

}

void MainWindow::setMatrixTops_Slots(QList<int> FengChangs, QString windAve, QString powerCount)
{
     int FengJiCount=getMatrixTopFengJiCount(ui->stackedWidget_2->currentIndex());
    this->setMatrixTopStates(ui->stackedWidget_2->currentIndex(),FengChangs);

    if(topMatrixStates.count()>0){

           p_matrixTop->p_num[1]->setText(QString::number(topMatrixStates.at(0),'g',4));
            p_matrixTop->p_num[2]->setText(QString::number(topMatrixStates.at(1),'g',4));

            for(int i=0;i<topMatrixStates.count()-2;i++){
                p_matrixTop->p_state[i]->setText(QString::number(topMatrixStates.at(i+2),'g',4));
            }

     }
    else{

        p_matrixTop->p_num[1]->setText("");
         p_matrixTop->p_num[2]->setText("");

         for(int i=0;i<7;i++){
             p_matrixTop->p_state[i]->setText("0");
         }
    }



     topMatrixStates.clear();
}




void MainWindow::on_pushButton_clicked()
{


}

void MainWindow::menuStart()
{
    p_matrixmenuForm->close();
    v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->setChecked();

  menuFlag=false;

   actionControl->setId(0);
    actionControl->setType(1);
   actionControl->doReload(v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index));
   actionControl->doControlOne();

  v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->cleanChecked();

}

void MainWindow::menuStop()
{
    p_matrixmenuForm->close();
    v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->setChecked();

   menuFlag=false;

   actionControl->setId(1);
    actionControl->setType(1);
     actionControl->doReload(v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index));
   actionControl->doControlOne();
    v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->cleanChecked();
}

void MainWindow::menuReset()
{
    p_matrixmenuForm->close();
    v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->setChecked();
   menuFlag=false;


    actionControl->setId(2);
     actionControl->setType(1);
    actionControl->doReload(v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index));
    actionControl->doControlOne();

     v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->cleanChecked();
}

void MainWindow::menuRepair()
{
   p_matrixmenuForm->close();
    v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->setChecked();

   menuFlag=false;

   actionControl->setId(3);
    actionControl->setType(1);
   actionControl->doReload(v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index));
   actionControl->doControlOne();
    v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->cleanChecked();
}

void MainWindow::menuUnrepair()
{
    p_matrixmenuForm->close();
    v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->setChecked();


   menuFlag=false;
   actionControl->setId(4);
    actionControl->setType(1);
   actionControl->doReload(v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index));
   actionControl->doControlOne();
    v_matrixFengChang.at(matrixmenu_row)->DomainObjectTurbines_One.at(matrixmenu_index)->cleanChecked();
}
